Ubuntu – keepAlive in Apache causing apache to reach its max_clients

apache-2.2keep-alivekeepaliveUbuntuweb-server

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.

Best Answer

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.