Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My wordpress blog is running without any problem with following apache prefork setting for months (~4000 DAU):

<IfModule mpm_prefork_module>
StartServers    2
MinSpareServers 5
MaxSpareServers 10
ServerLimit     50
MaxClients  100
MaxRequestsPerChild 3000
</IfModule>

This month, I got 5000 daily-active-user which is not a spike but steadily increasing. Last 3 days, apache starts consuming all memory (1GB Ram - VPS) and server doesn't respond. I tried to change a lot of setting but it still crush randomly.

Here is my recent setting:

<IfModule mpm_prefork_module>
StartServers    2
MinSpareServers 3
MaxSpareServers 6
ServerLimit     100
MaxClients  50
MaxRequestsPerChild 3000
</IfModule>

wordpress supercache plugin and google sitemap plugin are some I'm using. Could anyone kindly give me some hint what to do to stop apache crush? Thanks all in advance!

Apache Version - 2    
PHP Version - 5.2    
MySQL DB - 5
Wordpress - 2.9
share|improve this question

3 Answers 3

You only have 1GB of RAM. Take a look at how much a single httpd process is using and divide your 1GB by that (leaving a bit of room for the OS and so on). Since Wordpress is a php program, it's very likely that your memory usage per worker is significantly higher than 20GB, which is the limit at which you can support 50 workers as in your original config. (50 * 20GB = there went your RAM.)

How many worker threads do you have running right now, and what is their memory use?

share|improve this answer

The first think you need to do is edit your MaxClients to be 100. MaxClients and ServerLimit are effectively synonymous and should always be set to the same thing. If they differ then the lowest will be used.

ServerLimit 100 MaxClients 100

Assuming your server can handle 100 clients then that may help. Often Apache crashes because the settings you are using don't allow it to use all the CPU and RAM avaiable, which results in queueing of requests which eventually take down the system, even if they could have been handled speedily if the settings were different. You should investigate all the other MPM related settings in other responses on this site, as well as learning about and tweaking your Keepalive and Keepalivetimeout settings to make sure they are optimal.

I also recommend setting up mod_status and /server-status/ (the same thing) so that you can check your server when it is unresponsive to see how many processes there are and what kind of state they are in. You should also watch the server with top/htop while there are problems to see what patterns the RAM and CPU's create.

share|improve this answer

if supercache is running, and your visitors don't have cookies enabled, they should be served the static file through the mod_rewrite (provided the mod_rewrite rules are in place correctly). If you are getting hammered by search engine bots or users that are logged in, the site is viewed live.

I suspect the issue is probably more related to mysql taking too long to respond to the queries while building the sidebar.

When this happens, can you do:

mysqladmin -u root -ppassword processlist > /var/tmp/mysql.processlist
ps aux > /var/tmp/processlist
uptime > /var/tmp/uptime
free > /var/tmp/free
iostat 5 5 > /var/tmp/iostat
vmstat 5 5 > /var/tmp/vmstat

I suspect that the first one will show a dozen locked queries. If you're running the calendar widget, that would be the first thing to remove.

share|improve this answer
    
Thanks. I forgot to mention that I'm also using widget-cache plugin :D So I'm sure there won't be mysql long query for Sidebar. –  Devyn Sep 11 '10 at 19:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.