I may be off base, but I think this technique would be ineffective since the server process would be kept busy with an open connection to the browser. Eventually you'll run out of processes what with all the clients that end up waiting for something to happen. HTTP is a pull protocol. :)

The best that I can think of is some sort of queue system (like a message queue?) would be more appropriate to allow the browser to poll the server periodically to see if the info is available. Once the info becomes available, then the server can send it to the browser. Thousands of light requests are better than hundreds of heavy ones.

But it seems to me that you're leaning towards some daemon that runs in the background on the server, generating long-running responses to requests that come from the server. This is close to what you described with request A and B, but I'd have the actual request handled by another daemon.

I can get into further detail and speculation, but maybe we'll leave that as homework.

--Joel


On Nov 12, 2009, at 1:53 PM, Nicolas George wrote:

Hi.

There is an increasingly popular technique to emulate server- initiated push
over HTTP. I'm sure everyone here knows it well, but for the sake of
completeness: the clients sends a XMLHttpRequest to the server in the
background; the server does not answer it immediately, but keeps it for later when there is actually something to say to the client; if the request
timeouts, the client re-sends it.

I am wondering if this technique is usable with Apache in general and
mod_perl in particular.

The obvious solution is to have the request handler sleep until it has
something to answer does not work, since it requires a worker thread and a perl interpreter for each waiting client, and perl interpreters are few and
expensive.

The ideal solution would be if some part of the request handler could put the current request (A) "on hold". Later, the handler for another request (B) could retrieve the request A and generate an answer for it, or at least
wake it up.

Is something like this possible with Apache and mod_perl?

Regards,

--
 Nicolas George

Reply via email to