I'm writing a web application with lots of AJAX calls.
When I run two simultaneous jQuery.post()
requests on PHP scripts, the second request is only returned when the first finishes.
The second requests always waits for the first to succeed, even if I'm sure it should be faster.
(For information, the first request is expected to run for about 10 secs., whereas the second one should only last a few microsecs.)
Shouldn't this be completely asynchronous?
The PHP server seems stalled.
Is there a PHP configuration item which defines how many concurrent scripts can be launched?
I hope my question is clear enough.
Do you use PHP's native session handler? If so, be aware that session_start()
locks the session; the same session cannot be opened in another thread/process untill the session is closed in the thread/process.
This can be solved by just removing the session_start()
call in either (of both) scripts, or by using something like session_write_close()
to close the session ASAP instead of just waiting for the script to finish.