Linux – Does our VPS have its kmemsize limit set too low

linuxopenvzvirtuozzovps

Short Version:

Are there any official guidelines on what the kmemsize
barrier and limit should be set to for a container in
Virtuozzo/OpenVZ intended to be used as a Web server? We've found
posts in blogs and forums that
say that kmemsize should be at least 10% of vmguarpages (after they
are converted to the same units). Sadly, nothing we've found cited an
authoritative reference (or even a reason) for this 10% assertion.
Any idea where that 10% idea comes from?

Long Version:

A client of mine has a website on a 1and1 hosted VPS running CentOS
5.9 64bit. The site is extensive, but of particular note is an online
survey that is typically done by groups of people at the same time
from the same location (picture a classroom). Sometimes (but not all
the time) when a group all starts the survey process at about the same
time, we see a huge spike in the kmemsize "held" value on our VPS. At
first this was causing us to exceed the kmemsize limit, increase our
kmemsize failcnt, and send errors to our users' browsers. By
adjusting Apache's MaxClients I can keep us from exceeding the
kmemsize limit. However, if we peak just below the limit, http
requests get queued and the site slows to a glacial crawl, pages
literally take minutes to load, it's arguably no better than crashing.
It seems quite clear that we need a higher kmemsize barrier/limit.

That's the background. My real question is about whether our current
limit is reasonable. We are supposed to have 1G of RAM "guaranteed"
(vmguarpages barrier is set to 262144), with possible bursts up to 4G.
But I've noticed that even when we are near or at the kmemsize limit,
free still reports that we're using less than 600,000k of memory.
/proc/user_beancounters reports our kmemsize barrier at 31457280 and
the limit at 34603008. As referenced in the Short Version above, we
found sites claiming that the kmemsize should be set to at least 10%
of the "guaranteed" memory set by vmguarpages. Doing the math I'm
showing that we're at

kmemsize barrier = 31457280 B = 30 MB = about 3% of the vmguarpages barrier of 1024 MB

This seems consistent with the idea that (according to free) we never
seem to use much more than half of our total memory "guarantee". So,
we want to just call 1and1 and say "wow, this service you're offering
doesn't meet the minimum recommendations for VPS's, and as such it's
practically impossible for us to actually use the amount of memory
that you are guaranteeing us". And, if they won't listen to reason
and fix it, move to another provider. However, both to make my point
with the provider and to justify the move (if necessary) to the
higher-ups at my client's organization, I'd love to be able to cite a
more authoritative source for this "kmemsize should be at least 10% of
guaranteed memory" idea.

Best Answer

Look at the kmemsize entry on the Parallels knowledge base.