Building a Modern Web Stack for the Real-time Web
igvita.com
igvita.com
I might be fuzzy on my 0MQ knowledge and Mongrel2 but I thought PUSH/PULL are distinct socket types from PUB/SUB...
The reimplementation side of things is one more strike against software patentry, at least.
Novadays I can hold 1.5M open sockets on single server ...
Also, there's an attempt for 0MQ module for Nginx: https://github.com/FRiCKLE/ngx_zeromq
Once a request enters your "back office" it should all be message oriented, over persistent connections, with flow control / QoS, and the like.
Yes, replacing or modifying TCP would be a long, slow process, but so is re-implementing all its functionality at the application layer. Google introduced SPDY over two years ago (Nov 11, 2009), and as the article points out, there is still a whole lot of work that needs to be done before it lives up to its promise.
Edit: I confused web sockets with SPDY. I have to go read up on what these things actually are.
In many cases, you don't need bi-directional communication.. Which is also why HTML5 spec introduced Server Sent Events (SSE): http://www.igvita.com/2011/08/26/server-sent-event-notificat...
Ever edit a document with multiple people, at the same time? Much easier with web sockets.
Ever get a notification that a new email has arrived the second it arrived? Much easier with web sockets.
And yes, there's chat and messaging.
There are many more scenarios that will become evident as people start using the tech. It is a step up from XHR.
Thanks, this is the simplification I was after.
Or... don't have to deal with concurrent editing/locking mechanism? WebSockets do that for us?
Nope. However, it will allow you to contact any connected client at will from the server-side. Try doing that with XHR without constantly polling the server.
SSE, on the other hand, basically is long-polling and keep-alives, but with better defined behavior and a nicer API on the client side.
In addition, TCP slow start, window sizing, etc, work against you when it comes to optimizing for latency: http://www.igvita.com/2011/10/20/faster-web-vs-tcp-slow-star...
Aside from the overhead you and others mention, there is a bigger problem. For most server-side languages, once a request is initiated, it is very difficult to feed new data into that request and make it perform additional functions. Most requests get their input data from GET or POST. What if an external server outside of the one that is handling the request needs to contact one of the clients?
Using long polling/SSE, you essentially have to have the thread/process handling the request also poll any external sources for information for any potential events that might need to be triggered. This turns into a huge mess very quickly. Especially since each polling/SSE request thread/process is isolated from the rest, forcing you to do really funky stuff to coordinate everything.
This isn't as much of a problem with web sockets. Your web socket server has access to all of the connected clients and you can create a web socket interface in any external servers to allow them to talk directly to the proper clients. It's cleaner.
Web sockets isn't perfect. I had to implement a proper client for web sockets in PHP so that it can talk to my Node.JS websocket server. It was horrible. But it was less horrible than setting all of that up with long polling.
How does one pronounce that? Yur-m-k?
http://webcache.googleusercontent.com/search?q=cache:zsS5aXX...
http://answers.yahoo.com/question/index?qid=20100101105722AA...
(but really, it's ZeroMQ)