0

How can I increase the number of simultaneous connections in apache2? I'm using a javascript application that polls the server regularly and I'm trying to prevent clients from getting locked out. I know I should switch to a non-locking webserver, but until that, is there any kind of hack I can do in apache to optimize this? Thanks.

2 Answers 2

2

Perform a search on this site for 'MaxClients' which should turn up quite a bit of information to get you started.

There may be a few directives you want to look at depending on your server resources that could affect the number of simultaneous connections and thus performance of your web server. Here are a few examples (some may or may not need to be configured depending on your environment):

  • StartServers
  • MaxSpareServers
  • MinSpareServers
  • MaxClients
  • ServerLimit
  • MaxRequestsPerChild
  • KeepAlive
  • KeepAliveTimeout
  • MaxKeepAliveRequests:
0

On the Apache level you'll want to maximize the MaxClients value without ever running out of RAM. You could, for example, set MaxClients to 1000 and it would run fine until you had so many concurrent connections that you run out of RAM and begin to use the swap, at which point your server's performance will plummet.

As a rough guide you can run top and look at all the httpd entries taking the difference between the RES and SHR columns. This value is the approximate memory used by the Apache client processes. Divide the total number of memory you wish Apache to use by this number to get an initial MaxClients. For example, for an average Apache process size of 20MB to use 3GB works out to 3000/20 = 150 MaxClients.

If you want to increase MaxClients further you can try to reduce the size of the Apache processes by not loading any module you don't need.

As you mentioned, you may wish to consider an alternative web server, or possibly dual Apache web servers, to increase the number of concurrent connections possible. When Apache is configured to server dynamic pages (PHP, etc...) it is relatively memory hungry which puts a relatively low limit on how many connections you can have before running out of RAM. The usual choice in this case is to use a lighter web server (Lighttpd, Nginx, etc...) to serve all the static content and leave Apache to just serve the dynamic pages.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .