0

Why are 2 concurrent calls to apache2 not processed in parallel?

echo "Start: ".time();
sleep(5);
echo "<br/>End: ".time();

Open 2 tabs into chrome, and go to script. (same time)

Result from TAB 1

Start: 1321331382
End: 1321331387

Result from TAB 2

Start: 1321331387
End: 1321331392

How do I prevent this from happening?


Your questions hinted to the right answer.

session.auto_start = 1 was activated in php.ini The solution is to either start script with : session_write_close();

or session.auto_start = 0; into php.ini.

Thank you for the help.

Benjamin
  • 65
  • 1
  • 5

2 Answers2

3

When you use Chrome and request the same resource in multiple tabs, it will wait for the resource to finish downloading in one. The reason is that if the headers allow, the second tab will load from cache, rather than reloading it from the server.

This has nothing to do with your server configuration, but more to do with your flawed test method. Fire off a couple wget calls from the command line, and this will likely work as expected.

You can also verify that this is happening by using a debugging proxy, such as Fiddler, or packet sniffing software, such as Wireshark.

Brad
  • 146,404
  • 44
  • 300
  • 476
  • If I call localhost/x.php AND localhost/y.php , the same queuing problem occures. (x.php and y.php have same script) y.php shouldn't be waiting for cache since not the same script. I don't understand – Benjamin Nov 15 '11 at 04:44
  • @Benjamin, First, test with `wget` and/or Fiddler. If you can confirm the behavior there, then edit your post, specifying that you are accessing two different scripts (and explain how you tested), and post your Apache config file. – Brad Nov 15 '11 at 14:22
0

What are your apache settings? It's possible you have the config set to only run 1 server instead of multiple servers. So if it were set that way then it would be impossible to run concurrently.

frustratedtech
  • 425
  • 4
  • 9