Portal Home > Knowledgebase > Articles Database > Minimizing mysql memory usage.
Minimizing mysql memory usage.
Posted by dazappa, 09-28-2009, 11:45 PM |
Now, for starters I know this can be a bottleneck. Fact is, my site is beyond small, I'm talking miniscule. I'm currently running on a 256mb VPS and java and mysql will not play nicely with each other . The main problem is that my VPS provider does not have swap enabled, so all virtual memory is taken from the real/resident memory. Mysql uses 16mb resident and 125mb virtual, totalling ~150mb of memory usage. Ideally, I'd like to chop this virtual memory off, but I don't know what else to do as I've already modifed my config file to the best of my knowledge.
So I have this small java app which uses mysql, so mysql has to be started first, but then mysql has already chomped such a gaping hole in the ram that the JRE will not boot. If I run the java app without mysql started, the JRE will actually startup, but it's useless then because the database is mysql .
Config file:
|
Posted by Steven, 09-29-2009, 01:46 AM |
Cut down on the max connections. Stock it is 100 I believe.
|
Posted by cieslakd, 09-29-2009, 07:48 AM |
Two steps:
skip-innodb in mysql config"ulimit -s 128" in MySQL / Java startup script (in init.d)
Your virtual memory usage will drop drastically.
|
Posted by eth10, 09-29-2009, 08:43 AM |
Best way is to enable Mysql caching.. This can even reduced load on servers and increase speed.
|
Posted by dazappa, 09-29-2009, 07:29 PM |
That worked wonders on MySQL. Thanks a ton.
However, java appears to be the bottleneck, sucking up all available ram with and without setting the ulimit. Server's got about 180mb free with mysql running, and I even tried tightening Java's belt further by setting the ulimit to 64, but ulimit doesn't seem to have an affect at all.
@eth10 : Well no need now, really, but yes I think MySQL caching would use more ram (possibly moving it off the virtual), but I won't bother just yet
Well, I suppose I might have to go poke around sun's forums for tips on shrinking java's mem usage..
|
Add to Favourites Print this Article
Also Read