rdaruszka wrote:
Code:
<IfModule mpm_worker_module>
StartServers 1
ServerLimit 10
MinSpareThreads 5
MaxSpareThreads 20
#ThreadLimit 25
ThreadsPerChild 5
MaxClients 25
MaxRequestsPerChild 1000
</IfModule>
This looks reasonable, although MaxClients might be a bit low for mpm_worker. But I'll defer to others here since I'm not an apache expert.
rdaruszka wrote:
Code:
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
FcgidConnectTimeout 20
</IfModule>
Caveat for this section of my post: I'm a lighttpd user, so I'm thinking in terms of Lighttpd's fastcgi module.
Back to the age-old topic, "Apache's default settings are insanely stupid", FcgidMaxProcessesPerClass defaults to 100 processes. At PHP's max memory load, that'd be about 13 gigabytes of RAM. A sane limit for this setting is 8. The default of 100 means you can handle 100 simultaneous requests, but since you've only got access to four processor cores, that's pointless. 4 is theoretically enough to max out your CPU resources, but because stuff can be waiting on IO or other things, 8 gives you a 2:1 ratio to help keep those processors busy. Anything beyond that is starting to get pretty pointless on a quadcore processor unless you've got really long-running scripts (which a forum tends not to). You've already got 13 processes that I can see in that 'top', so you're already getting more than you need.
With lighttpd, at least, if there is a request that comes in while all 8 processes are busy, then it queues. That's the best policy, because it's better to queue up the requests than trying to serve them all at the same time if you've got an insane load spike.
rdaruszka wrote:
I'm not only trying to handle the regular traffic but deal with some rather sharp peaks of traffic I get on occasion. Before I got settings more calmed down I had a bunch of users show up and the whole place OOMed out on me. To give you an idea of what is "normal" for unexpected traffic I've had a single user show up and make 800 posts in one day, they brought the entire days average up by 3 requests per second. I also have had bursts where 20-40 new users will just show up and start posting 2-3 times per minute each on top of their browsing. That's why I have my max clients up as high as I do.
OOMs only happen because the webserver is misconfigured. No amount of load should cause the server to OOM, even if it's enough to make it slow to a crawl. Excess requests should be queued, so an OOM is indicative that you've configured your server to try to handle too many simultaneous requests.
40 users posting 3 times per minute is only 2 posts per second. That's pretty low load, not a huge load spike. Besides, for all this stuff, your database is probably the bottleneck if anything. Also, remember that 40 users posting 3 times per minute are not consuming 40 clients worth of resources. If your forum software is very slow and it takes half a second to process a request to make a post, then that user consumes one client worth of resources for half a second, and then is not connected to your server for the next 19.5 seconds... although keepalives might change this.
Again I'm really at a loss to explain the behavior of the software I just don't know enough about what I'm working with. If anyone can give me some idea of what I'm doing wrong I'd appreciate it.
rdaruszka wrote:
I'm not sure how to lower the number of PHP processes, where do I need to go in config's to handle that sort of thing?
I could tell you with more authority for lighttpd... If these settings are equivalent to what I'm used to, I would set FcgidMaxProcessesPerClass to 8, and FcgidMinProcessesPerClass to 4 (although the default of 3 is probably fine)... I'd wait for more apache-oriented people to comment.