I am trying to scale to 4000 concurrent connections on a ubuntu/apache box.

It is 8 core / 64gb ram, so it is not hitting memory or cpu, or any resources for that matter. The problem is with configuration. running on aws.

Serving a static file that says 'hello world';

What i have tried so far:

<IfModule prefork.c>
StartServers       500
MinSpareServers    2000
MaxSpareServers   4000
ServerLimit      5000
MaxClients       50000
MaxRequestsPerChild  10000

It works perfectly until 1500 concurrent users, then every connection added after that fails or times out.

What else can i look at?

  • 1
    Are you sure you're not hitting your RAM limit? The prefork MPM uses a lot. 1500 x 40MB = 64GB. Show us your measurements. – Ladadadada Feb 21 '14 at 8:45
  • @Ladadadada Memory doesn't work that way, I'd suspect theres < 1G of usage for that type of request. +1 for the measurements though. – Matthew Ife Feb 21 '14 at 8:48
  • Actually, a more reliable way of finding what's wrong would be to examine the failures in greater detail. What exactly do you mean by fails? TCP RST packet? 503 response? Something else? And what stage do the timeouts occur in? The three-way handshake? While waiting for the response? After the headers but before the body? Is there a pattern you can use to predict whether you will get a timeout or a failure for a given request? – Ladadadada Feb 21 '14 at 10:06
  • 2
    Is there anything in any logs? What are the ulimits? – Jenny D Feb 21 '14 at 10:49
  • @Ladadadada: 20,000 concurrent connections on Apache pre-fork in 24Gb - see stdlib.net/~colmmacc/Apachecon-EU2005/… – symcbean Feb 21 '14 at 12:00

Have you tried adjusting Apache's ulimit? It's set in /etc/apache2/envvars.

## If you need a higher file descriptor limit, uncomment and adjust the
## following line (default is 8192):
#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'


Try this setting it will help

keepalive: On
keepalivetimeout: 5
maxclients: 1500
maxkeepaliverequests: 100
maxrequestsperchild: 100000
maxspareservers: 100
minspareservers: 50
serverlimit: 2560
startservers: 50
timeout: 300

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.