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.

By default, Apache2 seems to allow only 1 connection per IP address.

How do I configure Apache2 to allow multiple simultaneous connections from the same IP address?

Here is my situation:

  1. a web app being hosted on a server.
  2. a remote client makes an request that may take 15 seconds to complete.
  3. the same remote client makes another (independent) request.
  4. at present, the 2nd request sits in a queue until the 1st request completes, since Apache2 seems to impose a limit of 1 connection per IP address.

How do I override this default behaviour and allow the 2nd request to be processed in parallel?

thanks in advance, David Jones

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

This topic is a bit outdated but i hope that my post may be useful for someone who is experiencing similar problem.
I have noticed that such a behavior is PHP related if you are using built-in sessions functions and session data is kept in files. PHP acquires an exclusive lock of the session file and if another process is trying to start session it waits until lock of this file will be released. So the simpliest solution is to call session_write_close function (which releases lock) as soon as session data is not needed anymore

share|improve this answer
add comment

That doesn't sound right. Apache doesn't limit it to one connection per IP. It sounds like whatever you're requesting from the server is causing the holdup. Apache is likely passing both (or more) connections to your app, and the app is causing the bottleneck.

Can you elaborate on your setup a bit further? What is your app written in? If you throw up a static HTML page, do you get the same result?

share|improve this answer
    
This PHP illustrates the problem I am trying to solve. It flushes and sleeps, repeating several times. In Firefox, partially rendered page updates every time PHP flushes. Visiting from same IP, 2nd client waits until 1st instance is done. Visiting from different IP, 2nd client starts rendering immediately. (2 processes run in parallel) <code> <? // puzzle.php $k = 4; $n = 5; $cr = "\n"; ?> <html><body> <? for ($i = 0 ; $i < $k ; ++$i) { echo '<p>Sleeping ' . ($i+1) . '/' . $k . ' ...</p>' . $cr; flush(); sleep($n); echo '<p>Awake.</p>' . $cr; } ?> </body> </html> </code> –  David Jones Aug 18 '10 at 18:36
    
Hi David, this is definitely something related to the way your code is run, specifically the sleep() command. I just ran this code on my server and I experienced the same thing. Hitting regular PHP sites work fine from simultaneous connections from the same IP. Looking up the sleep() function (php.net/manual/en/function.sleep.php), it states: "Delays the program execution for the given number of seconds". You're probably using the preform module which could account for the 1 IP per connection. If you switch to the worker module, do you get the same result? I'll try testing on my end. –  vmfarms Aug 18 '10 at 19:14
    
Hi David, I've done some more testing and I can confirm that the issue is related to the preform module. From the same IP, Apache will send the same connection to the same forked process. The sleep() function halts all PHP execution for that process, including any connections in the queue. It's specific to the sleep function though. All other functions will allow simultaneous execution. –  vmfarms Aug 18 '10 at 19:45
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.