Thursday, February 9, 2012

Optimize Apache Server

I came across a problem of my Apache web server recently which serving two Wordpress websites for around 400 users. The apache server freezed and could not response to any HTTP requests when too many users visit the sites at a short period. After googling the problem, I found that it is related to the memory consumption of apache server and the PHP scripting engine. My VPS server has 1G physical memory and 1G swap allocated. I used the "top" command to check the resource usage during a hang, I found nearly all memory were used up and many apache processes (around 20) were "locked" in the D status. A restart can really help the problem at the moment, but for the long term it'd better reduce the resource used by apache. Here are some posts I find pretty useful:

Running out of swap space on web servers, what to do?
http://serverfault.com/questions/110207/running-out-of-swap-space-on-web-servers-what-to-do

Low Memory Apache Configuration:
http://wiki.vpslink.com/Low_memory_MySQL_/_Apache_configurations

No comments:

Post a Comment