I have a LAMP server that can be serving ~400 requests per second at times, the server configuration is:
CPU: Intel Quad Core Xeon X3430 (4 x 2.40 GHz, 8MB Cache)
RAM: 16 GB REG ECC DDR3
HD: 500 GB Enterprise Grade SATA II
OS: CentOS 64 Bit (Latest Stable)
Apache2 prefork config:
StartServers 128
MinSpareServers 16
MaxSpareServers 64
ServerLimit 1500
MaxClients 1500
MaxRequestsPerChild 10000
At peak times the server load is very high, cpu utilization around 90% and load average around 130
I'm not sure it's server hardware limit or my prefork config have something wrong - What could be the problem?
You are allowing Apache to spawn up to 1500 children to serve requests (
ServerLimit
/MaxClients
) -- It's no wonder your server load (the number of processes waiting in the run queue) is getting enormous!My first suggestions at 400 requests per second with the numbers you're quoting in your question would be "Move the MySQL server to its own box" or perhaps a better choice: "Add another web server and load balance your requests".
To help you figure out how to size the additional server follow the advice HDDP500 gave in their answer to figure the average size of an Apache process. Figure out how many apache processes you want to run on the new server and determine how much RAM you'll need to handle them. Remember to add a safety margin (a gig or two).
Figuring out CPU requirements (speed/number of cores) is a little more difficult - You will need to take into account how much "work" the server has to do to generate each page. A tool like XDebug can help you out here by telling you how long it takes to generate a page (you should perform this test on an unloaded server as well as one under load, but you should also not use a tool like XDebug on a production server in most cases.)
What is the average size of your httpd processes?
Run this command when the server is under load:
That will tell you approximately the average size of an Apache process.
Your MaxClients is probably way too high.
Take a look at your CPU interrupts and see where the bottleneck starts (via
top
); as mentioned before, It'd be a good idea to dial down yourServerLimit
/MaxClients
.Depending on your consumption, this may (should) speed things up as you lessen the ability of the box to starve itself of CPU.