Checking Limits on OpenVZ / Virtuozzo

Do you use virtual server hosting for your websites? It’s commonly known as VPS. Most hosting companies now uses Virtuozzo, a proprietary operating system virtualization product produced by SWsoft, Inc.

The OpenVZ project is an open source community project supported by SWsoft and is intended to provide access to the code and ultimately for the open source community to test, develop and further the OS virtualization effort.

A couple of months ago when I have not tried OpenVZ, a friend asked me about a problem he is facing with his VPS which is hosting streaming videos and receiving millions of hits per day. He received errors such as:

  • cannot fork
  • Error running script: not enough memory
  • Fork failed

Now that I have deep knowledge in OpenVZ I know what causes the problem. The problem is that his running software and services were using resources more than allocated by the hosting company. If you are using such service, one good way to check is by executing this command:

# cat /proc/user_beancounters

The output would look like this:

   uid  resource           held    maxheld    barrier      limit    failcnt
  101:  kmemsize         473318     927071    2752512    2936012          0
        lockedpages           0          0         32         32          0
        privvmpages        1611      62436       4915       5357         40
        shmpages              1         31       8192       8192          0
        dummy                 0          0          0          0          0
        numproc               9         15         65         65          0
        physpages           887      32985          0 2147483647          0
        vmguarpages           0          0       6144 2147483647          0
        oomguarpages        888      32985       6144 2147483647          0
        numtcpsock            0          4         80         80          0
        numflock              1          3        100        110          0
        numpty                1          1         16         16          0
        numsiginfo            0          3        256        256          0
        tcpsndbuf             0       7856     319488     524288          0
        tcprcvbuf             0      95460     319488     524288          0
        othersockbuf       6660       8880     132096     336896          0
        dgramrcvbuf           0       8364     132096     132096          0
        numothersock          5          8         80         80          0
        dcachesize            0          0    1048576    1097728          0
        numfile             168        399       2048       2048          0
        dummy                 0          0          0          0          0
        dummy                 0          0          0          0          0
        dummy                 0          0          0          0          0
        numiptent            10         10        128        128          0

These info are important because it is most likely that you can’t see what configurations your VPS is running with.

Simple meanings of the columns:

  • resource – name of the resource
  • held – current usage
  • maxheld – max ever used
  • barrier – soft limit of the resource
  • limit – hard limit where the VPS will never use more
  • failcnt – fail count

The most important thing to see is the failcnt column, where in an ideal situation you should see only zeros. In this case, you see that privvmpages have failed 40 times because I on purposely lowered the memory allocated for the VPS and run some programs.

You will never be able to change the resource allocation from within the VPS but at least you know what your problem is and is a good point of discussion with the hosting company.

And oh yes, the values are in 4k blocks which means that if the setting is 4915 the actual value is 19660k (4915 * 4k). Of course this is only applicable for some, and not for countable values such as numpty.

Good luck!

0 Shares