kmemsize limitation


New Member
For the first week that I bought my VPS at Knownhost, I had a VPS M account with an extra 256 MB RAM (384MB RAM total), but the system kept showing kmemsize overloaded. so I had to upgrade my VPS to VPS L +256MB RAM (512MB RAM total).
During the past several weeks I've been watching the system RAM usage record and I found actually it had never really exceed 300MB, which means actually I have been spending money for up to 200 MB RAM that the system doesn't really use. I don't know how kmemsize limitation works but it is confusing me.
Any suggestions?

kmemsize parameter controls amount of low (or kernel) memory available for your system. Kernel memory is used for all internal kernel data structures (except network buffers) associated with your VPS. Kmemsize usage depends on number of processes you run, number of file descriptors or network connections you have open and so on. Usually kmemsize limit is hit by the customers who have "broken" php or mod_perl scripts where a lot of files or sockets gets created/opened and remain open for a long period of time even in case if file descriptor / connection become unused.

See my identical question a couple months ago, where we discussed some remediation techniques:

I did manage to get things mostly in control through some careful MySQL process management. However, when I've got ~100 active apache processes each performing a dozen or so queries, that's still the resource that gets exhausted first in the configuration here. :(

Though buying a larger VPS doesn't get you a bigger kmemsize, you can use excess RAM to make bigger caches for MySQL and a PHP accelerator, speeding up your site and thus reducing the lifespan of processes and lowering your kmem usage.

There are "gotchas" in those tradeoffs, too. If you have 300 MySQL tables but a table_cache of 128, you might be tempted to bump that up to speed things up. However, if only 60 of those tables are frequently used, bumping it up to 300 is going to add a couple meg to your kmemsize keeping all those files open without an appropriately offsetting increase in performance.

Tweak and cat /proc/user_beancounters a lot to find out what works best with your application/traffic mix.