Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

After scratching my head trying to figure out why my site was responding so slowly even though the server resources are fine, I finally checked the Apache status and found:

78 requests/sec - 0.7 MB/second - 8.5 kB/request
256 requests currently being processed, 0 idle workers

It appears that my apache is literally maxed out with connections. Anyone trying to visit my site gets put on a "waiting list" until Apache is free again.

It seems I have two options.

A) Raise the max connections limit above 256. Although according to this article it's not so easy:

By default, the MaxClients parameter has a compiled in hard limit of 256. This can be changed by recompiling Apache however. Some distributions, or hosting companies raise this limit to a very high value, such as 512 or even 1024 in order to cope with large loads.

B) Locate scripts that are taking up too much time. This seems a lot more tricky to me, since most apache processes just appear and then disappear again. Also, my sites PHP scripts are optimized pretty well...and once again, server resources are fine:

Server load 2.69 (8 CPUs)   
Memory Used 25.33% (2,039,108 of 8,048,804) 
Swap Used   1.32% (54,156 of 4,095,992)

Which option (if either of them) should I chose and how should I do it?

EDIT

More information: Server Version: Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/1.0.0-fips DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635

HTTP Conf: http://pastebin.com/yBeLt6mP

Parital Request sample: http://pastebin.com/vzUVDMPR

Toggle Text-Wrap if the paste-bins show up weird.

share|improve this question
    
The article you cited is ~6 years old. Software changes. See Shane's Answer. –  Chris S Feb 23 '13 at 21:12
    
@ChrisS Even further out of date - the compiled-in limit was a 1.x thing (2.0 came out in 2002), and the article even explicitly links to the 2.0 docs. –  Shane Madden Feb 23 '13 at 21:46
add comment

2 Answers

up vote 8 down vote accepted

That article is inaccurate; MaxClients can be raised above 256 when using the prefork MPM (which is what I assume you're using currently based on your description of the problem). From the documentation:

For non-threaded servers (i.e., prefork), MaxClients translates into the maximum number of child processes that will be launched to serve requests. The default value is 256; to increase it, you must also raise ServerLimit.

ServerLimit is the one that has the hard-compiled limit, but it's way past where you should ever reach without your server running into some other bottleneck. Documentation:

There is a hard limit of ServerLimit 20000 compiled into the server (for the prefork MPM 200000). This is intended to avoid nasty effects caused by typos.

So, if you want to raise your client limit to something like 512, then:

MaxClients 512
ServerLimit 512

You should also take a look at which MPM you're using, as MPMs other than prefork are better for scale. See here for more information.

share|improve this answer
    
I see core.c and worker.c from running httpd -l. I guess that means I am running worker MPM? –  hellohellosharp Feb 23 '13 at 21:03
    
@hellohellosharp Indeed - in that case, you'll want to adjust potentially your MaxClients, ServerLimit, ThreadsPerChild, and ThreadLimit. Can you provide your current worker config from httpd.conf? –  Shane Madden Feb 23 '13 at 21:09
    
Yes...is there any danger in posting this publicly? Hopefully not, here it is: pastebin.com/yBeLt6mP –  hellohellosharp Feb 23 '13 at 21:11
    
Nope, no problems in posting most httpd.conf files. Just make sure you don't have something odd like comments with passwords/usernames/etc. These sometimes creep up in proxy configuration sections and the like too. Many people like to edit out IP and Domain names too, just so they don't attract attention –  Chris S Feb 23 '13 at 21:14
1  
the status module can show you these details. –  ETL Feb 24 '13 at 2:50
show 7 more comments

I would suggest that you use a reverse proxy, something like nginx or lighttpd can handle many more connections than apache. Depending on how your sites use htaccess you can also use nginx/lighttpd with fcgi and forego apache completely.

share|improve this answer
1  
Really?? He needs to add two lines of configuration to httpd.conf and your solution is to rip out most of the software he has running and replace it?! Every piece of software has it's problems, but uneducated misuse causes worse problems. –  Chris S Feb 23 '13 at 21:11
    
Ultimately nginx can handle more active connections, its up to the OP to decide what to use, I was just putting forward my suggestion. –  Shoshomiga Feb 24 '13 at 12:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.