views:

37

answers:

1

I am working on a php web application which involves calls to 3rd party web services. Recently I've run into problems because some of the web services are slow and/or time out. (When this happens the service throws an error after 5-6 minutes, which is handled by the web application)

However, the problem arise that while waiting for the result/timeout, all other connections to the web application in the browser (other windows/tabs in IE) stall. It seem to be a problem with the browser, because if opening a secondary window in another browser (e.g. Chrome) the web application serves pages with no delay.

I've considered setting up the web service call asynchronously (a separate server.side process, or an ajax call in the browser), but in the mean time I'd like to know why IE is putting all connections to the web app on hold while waiting for one page? Could it be that a custom header or other trivial markup trick would tell IE to go on with connections to other pages at the same host?

+1  A: 

the problem arise that while waiting for the result/timeout, all other connections to the web application in the browser

What you're seeing is normal and expected behavior, if you're using sessions. The default file-based session handler places a lock on the session file when the session owner makes a request. Once the request finishes, the lock is released. In the meantime, if the user makes any further requests, those requests will wait for the lock to be released before they can continue. This behavior prevents a race condition that could otherwise result in session data being lost.

If you aren't using sessions, or you've written your own session handler and it doesn't do locking (most do not, you have to code that behavior yourself), then yeah, IE's being freaky and I have no further suggestions.

I've considered setting up the web service call asynchronously

If the web service is unreliable, this is a good idea. You should consider Gearman, a work/message queue system. It has comprehensive PHP support as a PECL extension.

Charles
Even for people not using sessions, they have to verify session.auto_start is set to 0 in php.ini, because they may be using sessions without being aware of it.
Joeri Sebrechts
Thanks a lot for the info! I do use sessions, and it never occured to me that locking took place at the server, as 1) all other operations execute so quickly 2) Most operations are single-page
goorj