I have an Apache 2.2 running on ubuntu 11.4 with 16Gb RAM, for image hosting from mobile phones through GPRS,since connection is slow i have enabled keepalive and set time out to 6,**based on average loading time.But usually even with 10-20 users apache is reaching its max_clients of 300 and preventing further connections.But the interesting thing is even **with keepalive turned OFF Apache is reaching its maxcients and refuses to accept new connection

**KeepAlive ON /tried Off also

MaxKeepAliveRequests 100

keepalivetimeout to 6 (since lot of dynamic images and slow connection)

StartServers 100

MinSpareServers 100

MaxSpareServers 150

ServerLimit 300

MaxClients 300

MaxRequestsPerChild 3000**

What should i do,to improve performance without hitting max_clients.Caching and deflate module is also enabled.Is to ok to set maxrequestperchild to 10 to prevent reaching max-clients.

  • MaxRequestsPerChild has no relation to MaxClients. – adaptr Apr 20 '12 at 14:02

You're running apache 2.2 with the prefork MPM; this is notoriously unsuited to serve large numbers of concurrent connections.

Consider either switching to the worker MPM, or upgrading to apache 2.4.

Even apache 2.2 using the worker MPM can serve thousands of concurrent requests with 16GB of memory.

Especially on mobile devices, setting KeepAliveTimeout too low will hurt you; consider increasing it to at least 30 seconds.

  • the issue was with COnfiguration i have set Allowoverride None for /var/www/ ,but i thought it would increase performance and security since with Allowoverride All,then a request for index.html apache have to look for .htaccess inside /.htaccess /www/.htaccess,/www/htdocs/.htaccess etc,which affects performance badly.isnt that so???.After Changing this spawning of children is normal. – ananthan Apr 21 '12 at 7:51

Like adaptr, swith to the 'worker' MPM and scale to thousands of concurrent connections.

Note that the maximum duration of your connections is also controlled by the TimeOut Apache parameter : set it to a low value, because it is an 'idle I/O timeout' value. Well, not to low since GPRS clients are slow, but the default of 300 seconds is way to high.

Even with the 'TimeOut' parameter set to a low value, the clients still decide how many time they will hold a connection open. You might want to check mod_reqtimeout (http://httpd.apache.org/docs/2.2/mod/mod_reqtimeout.html) which helps a lot in at least blocking slowloris-like attacks.

It is possible to define other timeouts, but it depends on specific modules/usages. I control more stringent timeouts via mod_proxy and mod_fcgid. When it's possible to force a connection to never use more than N wallclock seconds, you know exactly what's your nominal arrival rate before your MaxClients is reached (it's MaxClients / N new conn/sec). It depends a lot on what you are running within your Apache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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