Java – Tuning OpenVZ Containers to work better with Java

javamemoryopenvz

I have a 8 GB RAM Server (Dedicated) and currently have KVM Virtual Machines running on there (successfully) however i'm considering moving to OpenVZ as KVM seems a bit overkill with a lot of overhead for what i use it for.

In the past i have used OpenVZ Containers, hosted by myself and from other providers and Java doesn't seem to work well with them.. One example is that if i give a container 2 GB RAM ( No burst) (with or without vswap doesn't matter) a java instance can only be tuned to use at very most 1500 MB of that RAM (-Xmx, -Xms).

Ideally, i wish to be able to create "Mini" containers with about 256MB, 512MB, 768 RAM and run some java instances in them.

My question is: I'm trying to find an ideal way to tune a OpenVZ container configuration to work better with Java memory.

Please, don't suggest anything related to Java settings, i'm looking for OpenVZ specific answers.. Though i welcome any suggestion if you feel it may help me.

Much Appreciated,
Daniel

Best Answer

You have to use RHEL6 (aka 2.6.32-, aka 042stab) kernel and configure your containers with VSwap. See http://openvz.org/VSwap for more details. It is done so by default in new installs.

If you want mini containers, assign the RAM you need and then two-four times amount of swap, to enable some "stretching" for CT memory. For example, for 256M that would be

vzctl set $CTID --ram 256M --swap 1G --save

Make sure other beancounters (especially privvmpages) are set to unlimited. Again, see http://openvz.org/VSwap for more details.