First off, Apache, nginx, or LightSpeed aside – if you’re running a server with 1000-2000 requests/second it’s time to start thinking about dual servers and load balancing. Depending on what you’re serving you can easily get more out of any of those servers, but at those rates you’re serving something important (or at least high-traffic), so you want redundancy in addition to the ability to handle momentary load spikes.
Start seriously considering a load balancing infrastructure i.e. HAProxy and NGINX.
You can certainly consider other high-performance web servers (nginx is very popular), or you can consider tuning your Apache configuration for better performance.
Some Apache suggestions.
Before doing anything else, read the Apache performance tuning documentation.
MaxRequestsPerChildis really only useful for containing resource leaks.
100 (your current value) is absolutely insane. You’re churning processes which kills performance.
0 (Never kill a child) is certainly viable if all you’re serving are static resources.
10000 (ten thousand, the default) is fine in almost all circumstances. 50000 (fifty thousand) is what I use for pure static HTML sites.
MaxSpareServerscan be tuned.
I generally set
MinSpareServersto the same value.
If there is a specific minimum number of spare servers you want to keep around, that is the number you should start with. A good value for this is your low-water-mark of simultaneous active connections.
MaxSpareServersshould be set to 75-80% of your high-water-mark of simultaneous active connections.
MaxClientscan possibly be increased.
If you have lots of free RAM and lots of free CPU, increase these numbers.
If you’re running close to resource saturation, leave them as-is.
- Use graceful restarts
You say you are seeing “momentary extreme peaks” in your load when Apache restarts.
This tells me you’re probably not using graceful restarts.
Whatever is causing Apache to restart, have it send
SIGUSR1to Apache rather than
SIGHUP(or heaven forbid, actually stopping and starting the entire server). This is far less abusive and disruptive to the system than a regular restart of a full stop/start.
- Consider other MPMs
You are almost certainly using the
preforkMPM if you’re on a Unix system.
Consider the Worker MPM instead.
Tuning for the Worker MPM is a little different
- Spend some cache
Apache has caching modules which can be used to hold frequently accessed data in RAM. This avoids a round-trip to the disk (or at least the filesystem layer) for frequently accessed data.
Configuring memory backed caching can give you a pretty big performance boost for a relatively small amount of memory.