Why Apache does not process multiple requests simultaneously from the same browser

I am not quite sure how to correctly formulate this question, so I will start with the script that I came across.

I have a bit of processing in my web application that takes longer than I would like the user to wait to control the page again, so I decided to process it with an ajax request.

The problem is that even if I unloaded this request into an ajax request, it seems that apache will not process further requests until the full request of the original processor has been completed.

I initially wanted to know how I could get around this problem, but since then I decided that this might be a bad idea in general.

However, I'm still wondering if anyone knows why apache behaves this way and what (if any) the configuration directive controls it. My initial thought was KeepAlive, but disabling didn't seem to change the behavior.

I run php through mod_php if that matters.

I appreciate any help that will be sent in the right direction!

+7
php apache2
source share
3 answers

Do you use file-based sessions? PHP will lock the session files for each request and maintain this lock until you execute session_write_close() or script completion / completion. A side effect of this is that all requests become serial, as they all fight for the same single resource (session file).

+11
source share

I am sure this is a session file. I have the same problem. I am running a long query, such as an insert of PHPMyAdmin SQL, which takes several minutes to process. While it is being processed, I try to open a new tab in the same browser and go to any page on my website, and it won’t go there until the initial PHPMyAdmin request is executed. If I open an incognito window in Chrome, which is the same browser, it works fine. If I open the site in any other browser, this is normal. So this is probably a file-based session that is used by default for PHP.

Others mentioned going to memcached. You can also save sessions to the database. Before you go to memcached, you can first use all session-based stuff. Copy the session variable to a temporary variable to close it and then close it. And then, if you need to set the session value later, open it and make changes, and then quickly close it.

+2
source share

Can you point to evidence that this is apache? If your apache installation is not optimal, most likely your page is waiting for something else, maybe you found that your ajax call is not asynchronous?

0
source share

All Articles