MySQL killing the server
I have a pretty popular blog running on Wordpress. It uses PHP4 and MySQL 5.0 DB. Once in a while it happens that the MySQL server makes the server run really slow. The website does not work at that time (Wordpress cannot connect to the DB) and all the operations (even an SSH login) take 10 times longer than usually. Restarting MySQL does not help. I need to kill it (killall -9 mysqld) and start it again. Then it just starts working perfectly like before.
I'm sure it's some kind of configuration issue. The server is running Debian Etch and it's a PIII with 512MB RAM. Do you have any ideas what the problem might be and how to solve it? If you need any logs, let me know and I'll use pastebin. I'm just not exactly sure where to look for. |
Maybe apache is waiting for the database connections and growing beyond your available RAM?
Try working out how much traffic you server at peak times (number of connections and size of threads) and configure your web server and database tightly to that. That should help stop the server overloading. |
Quote:
|
You haven't stated which version of Apache you are using. One of the directives to search on is MaxClients (http://httpd.apache.org/docs/2.0/misc/perf-tuning.html).
I can be a difficult thing to give specific advice on, as it depends on various things. The basic calculation is that if you have 128Mb of RAM and each Apache process uses, on average, 10Mb - then you should never have more than 12 at any one time (13 processes would be > 128Mb). Obviously these figures can vary greatly. The only time I have experienced something similar to what you are describing is because Apache is creating more processes than the box can handle. The processes don't start off using up the full 10Mb (from the example above) and so end up in a deadlcok each process waiting for the other to release memory before it finishes it's job. Reading up on MySQL configuration on their website could also be helpful (so that it fits well your Apache config). Many other things can help with this problem (tune your SQL queries, tune your HTML, add RAM). Maybe you are suffering from some other problem - but tuning your webserver config can never be bad :) |
Quote:
|
Hey Michux, if would help if you pasted your my.cnf file for better understand of your mysql performance.
|
Quote:
Code:
[client] |
So, any ideas?
|
I moved the MySQL server to another machine and it seems that it was not MySQL killing the server but rather Apache killing MySQL. I just experienced a similar problem on the server with Apache only -- some cached pages still show up but all those that require a DB connection display a message about DB problems. But MySQL on the other server was up and running and I could connect to it w/o problems locally. Killing apache and restarting it was the only solution to bring life back into the server.
The machine is a PIII with 512MB of RAM. Here are some apache settings that might be important to tweak: Code:
ServerType standalone |
As per my previous post, I'd recommend that you read up on Apache documentation (httpd.apache.org). Unless I missed it, you haven't stated which version you are using.
Your settings depend on what you are serving, to how many people and when. Here is a setting for commercial web server that primarily delivers dynamic mod_perl content, where each process tends to be 35 to 40 Mb (10Mb shared) with 1Gb RAM: Code:
<IfModule prefork.c> Code:
top | grep http |
Quote:
|
same issue
hi everyone,
I seem to be facing the same issue, it seems like instead of reusing the old unused apache2 processes. They just get bloated and apache spawns new processes to deal with new requests,it is a real killer on preformance. The only reason i can think of is that the processes are not either being recycled or killed i apologise if im being abstract but im quite new to apache. Any progress being made as i am stumped. |
Fixed with phpaccelerator
Quote:
Thus it seems the problem was PHP and mysql or apache were affected only as a result of poor PHP performance (or poor PHP code, this needs to be investigated since we use a lot of Wordpress plugins which may be causing problems). Anyway, hope this helps some of you :) |
All times are GMT -5. The time now is 11:09 PM. |