Tag Archives: ajax

PHP Session locks

At work we have a page that loads multiple PHP scripts (in parallel), using XMLHttpRequest.

Later, we noticed that if one PHP script responds very slowly (i.e. when we put sleep(120) inside), all the others are waiting till the first one finishes loading. In other words: the load is serial, not parallel!

What? Why?!
A little research revealed an interesting phenomena: PHP session locks the session file till the session is closed. By default, the lock starts with session_start() call, and ends at the end of the PHP script!

Continue reading

Ajax Parallelism

I've been asked to run few ajax requests in parallel.
Apparently the "A" in ajax stands for "Asynchronous", so each HTTP request made is non-blocking and unlimited HTTP requests should be made in parallel.

However, the browser limits the number of connections to a specific HTTP server. This is not a bad browser design: it's according to HTTP 1.1.

This can be tweaked (and thus breaking HTTP 1.1 compatibility):

FF: about:config -> network.http.max-persistent-connections-per-server

MSIE: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\MaxConnectionsPerServer (create it even if it doesn't exist, DWORD value)

Refs: http://support.microsoft.com/kb/183110