I'm trying to help a friend with his server after he told me his MySQL was using too much memory… It turns out it's not only using a lot of memory, but there are way too many mysql process running!
Here's the result of ps auxww|grep mysql
: http://pastebin.com/kYrHLXVW
So basically there are 13 MySQL processes, and there is only 1 client connected according to mysqladmin…
After a while, each of these process eat up to 50mb of memory so it ends up consuming a LOT of memory…
I'm using the my-medium.cnf config template straight from /usr/share/mysql… I restarted the mysql server but, as soon as it starts, the 13 processes are back… I have no idea what the problem could be… any ideas/suggestions would be really appreciated!
Best Answer
They're not using 13 * 50mb of ram -- They're probably using something like 70mb total. Remember that that linux will share unmodified memory pages between processes, so if your server is freshly started most of that memory would all be shared. In fact, since mysql is threaded there will only probably be even less memory allocated per thread. If you're concerned about the memory usage of each mysql process, look at
/etc/mysql/my.cnf
, and look at the variables in the mysqld section:key_buffers
thread_stack
thread_cache_size
max_connections
query_cache_limit
query_cache_size
Be warned though, that those are very powerful variables to tune, and you can easily kill your mysql performance setting them too low, or waste memory that could be used elsewhere by setting them too high.
One easy starting point to figure out the best way to tune your mysql instance is to run your app for a little bit, then run the mysqltune script, which will analyze your performance counters, then produce a recommendation on what you should change in your server config.