yehster wrote on Tuesday, May 01, 2012:
Only one AJAX call (or page load) can execute at a time when the script calls session_start
http://php.net/manual/en/function.session-start.php
PHP locks the session file until it is closed. If you have 2 scripts using the same session (i.e. from the same user) then the 2nd script will not finish its call to session_start() until the first script finishes execution.
If you have scripts that run for more than a second and users may be making more than 1 request at a time then it is worth calling session_write_close() as soon as you’ve finished writing session data.
So part of the reason the demographics page takes a long time to complete is that each AJAX get called synchronously.
I’ve done some initial coding and you can see the difference. (My vitals load in less than half a second where as before it was waiting until after the 2 seconds the clinical rules needed to complete).
https://github.com/yehster/openemr/tree/ajax-sessions-experiment
I’m not sure of other unintended consequences this might have though. I’ve scanned the files where I added session_write_close() to make sure that no attempts to change session variables are made after that point, but I could certainly have missed it.
Like I said, this issue applied to page loads in addition to AJAX, so when you load a new patient with the frames model, the encounters.php in the bottom frame has to wait for the demographics page to finish in the top frame.
Here is another useful explaination.
http://konrness.com/php5/how-to-prevent-blocking-php-requests/