High traffic optimizations
I am working on a client's site trying to get things optimized for the amount of traffic they have and thought it would be worth digging into the actual Apache settings. It's a 64bit server with 32 cores and 64GB of ram, and we were still experiencing outages. The thing is, when they were happening I was still able to log in via ssh and run htop, and the load averages were ~12, and it was using less than 14GB of the ram. I have seen servers with much fewer resources peak much higher on the cpu usage before actually crashing, and when that happened we couldn't even restart Apache without it hanging for 5+ minutes first. These are the current settings:
StartServers 5
MinSpareServers 10
MaxSpareServers 20
ServerLimit 500
MaxRequestWorkers 200
MaxConnectionsPerChild 10000
KeepAlive On
KeepAliveTimeout 5
MaxKeepAliveRequests 100
Timeout 300
The two main sites on there are Wordpress sites, they get mabye 1 million visitors/month and they are involving a bunch of logged in users interacting with each other, so I know it requires a large amount of resources to run the sites. I first started looking at the settings because initially I thought KeepAlive was off but I was wrong.
1) Do these settings look adequate for a server handling this level of traffic?
2) Are there other settings I should be looking at?
3) The Timeout is set to 300 (5 minutes), but when I was analyzing the traffic logs yesterday I noticed there appeared to be some requests taking over 12 minutes to complete, eg:
If the timeout is set to 300, shouldn't that request that was made at 15:13 have died by 15:18? Also, that file does actually exist and returns a 200 Ok in the other entries most of the time. Is this indicative of some other issue? Thanks. -Michael
xx.xx.xx.xx - - [11/Nov/2017:15:26:55 +0000] "GET /... HTTP/1.1" 200
xx.xx.xx.xx - - [11/Nov/2017:15:26:51 +0000] "GET /... HTTP/1.1" 200
xx.xx.xx.xx - - [11/Nov/2017:15:13:47 +0000] "POST /wp-admin/admin-ajax.php?action=http_worker&nonce=fb2c735fbb HTTP/1.1" 404
xx.xx.xx.xx - - [11/Nov/2017:15:26:56 +0000] "GET /... HTTP/1.1" 302
xx.xx.xx.xx - - [11/Nov/2017:15:26:54 +0000] "GET /... HTTP/1.1" 200
If the timeout is set to 300, shouldn't that request that was made at 15:13 have died by 15:18? Also, that file does actually exist and returns a 200 Ok in the other entries most of the time. Is this indicative of some other issue? Thanks. -Michael
-
Hi, It can be difficult to say which settings may be reasonable. While you have provided requests statistics, it's still entirely dependent on site code efficiency as well as general connection speeds from your clients. When you see outages, what is the error from the client side? Are you seeing any errors in the Apache error_log at the same time? You also didn't mention the Apache MPM or PHP handler you are using. I would recommend ensuring you're using a threaded MPM like worker, and a PHP handler like CGI or FPM or LSAPI. Regarding the timeout, where are you seeing the running time? The access logs don't provide that information. The 404 could be filtering from something like mod_security. Thanks, 0
Please sign in to leave a comment.
Comments
1 comment