Nginx module to turn it into a long-polling message queuing HTTP push server.
github.com
github.com
One of the guys from Google named it the "Comet Tornado Reverse HTTP Proxy" because we were talking about adapting Tornado, this look like exactly that.
(of course, the bugs in question seem to be concurrency related, so it might take a day or two or more to fix)
Clever suggestions and constructive forks are welcome.
set $push_channel_id $arg_id; #/?id=239aff3 or somesuch
Means that the ?id= querystring paramater is used as the push channel ID. Any idea if it would be possible to set it up so /channel/12345/ would result in 12345 being set as the push channel ID?
Maybe something like this...
location / {
rewrite ^/channel/(.+)$ /channel/?id=$1 last;
}
location /channel/{
#stuff
set $push_channel_id $arg_id; #/?id=239aff3 or somesuch
}It would be much nicer if you could make one server-side request for each event, and have nginx track which clients are interested in that type of event and even queue that event for a while for clients that are yet to connect.
If this does become an issue, it is a tradeoff between speed and memory usage and ease of implementation.
http://cometdaily.com/2008/09/30/why-flash-must-adopt-comet/
I am using it on port 443 (https).
.... and there goes half your potential users.
That aside, I also can't run flash on my iphone, or my blackberry.
Javascript on the other hand is supported nativity across the board.
The advantages/disadvantages listed on the juggernaut website seem fishy to me.
1) it's not hack
2) I don't know of js crashing your browser *more* then flash
3) Any browser that supports flash supports JS
4) You can use http over any port as well
With Comet you get the added benefit (which is small or large depending on your implementation) of http caching and you remove reliance on 3rd party libraries.Looks like I just rewrote what was previously mentioned in the articles about juggernaut
I've noticed it can keep http connections open for extremely long times.
The link covers a server side message passing interface.
I just glanced over it (do not use nginx) think it's just a more efficient way for your idle process to know if they need to send anything over the wire or if they can keep idleing.
It has a few interesting options. "messages" are passed by a "channel id" and you can have any number of long polling listeners on a channel, or you can error out the first or last connections on a channel so there is only one listener at a time. If you have multiple listeners the message becomes a broadcast.
You also have a configurable amount of memory to buffer messages in the event there is no listener on a channel, or the listener is busy (receiving a message I guess). You can also set limits on number of messages per channel and a timeout.
I can see the advantages of this easily. The connections in nginx are much less resource intensive then a rails or php fast-cgi. You'll end up using much less ram. I know python has twisted and there are few others webservers for other languages, but this would allow me to run a php based chat server and take advantage of long polling.
I like it.