Sayaka wrote:
That's why we'd have to use some Push framework instead.
Also, FlashChat operated on the same principles you mention (constant polling) and we had it for years. We even had 20+ people in Chat on many occasions during FlashChat's reign.
Hopefully Glode doesn't mind my using his messages to express his opinion on the matter as he is and has been our senior networking (and everything else) specialist..
Glodenox wrote:
In terms of communication technology, using Java or Flash has been a much better choice over JavaScript for years. Only recently has JavaScript started to become slightly more interesting since some browsers are now supporting a feature called "Web Sockets" (more on that at the end).
In the past, when you wanted to have a chat application, you needed to perform a frequent polling. Basically, sending a request to the server each 2 or so seconds, asking for new messages. Scale that to 20 people, and you've got 10 requests per second just for a chat. Commonly, such chats are also powered by a database and don't use any caching, so add 10 requests per second to the database as well. But admittedly, a well-written application could limit the resources required at that point. Still, it's fairly inefficient.
In comparison, a Java (or Flash) solution provided us with a completely different approach: the client would connect and open a connection with the server without closing it. That allows the server to be in control, by pushing out messages to all the clients as they arrive, without requiring those clients to ask for updates all the time. A database connection is no longer needed either, unless perhaps for logging purposes, as the messages are sent immediately to the clients when they arrive. Each of those clients will have a queue of messages on the server, so nothing should get lost. All this however demands more control over a server, as you can't run such applications on a lot of hosting solutions.
So basically, push systems > pull systems. As for Web Sockets: they provide practically the same thing as what Flash applications and Java applets do. A socket to open a connection with the server and receive messages pushed by the server without polling. Sadly enough, Web Sockets aren't really ready for common use yet as their support is still a bit spotty at the moment. I'd personally much prefer to use JavaScript as well over a Java applet or a Flash application. It's just not yet feasible.
Note: the FlashChat we have uses the pulling system. Therefore, it's not a good alternative.
He finished with this comment:
Glodenox wrote:
Seriously. Forget about pinging systems (or pulling systems, that's the same). It's not efficient, doesn't scale well and I'd even say that sort of systems belong to the 90's. Even if the database isn't accessed as often, it means that 4 people in the chat already double the average amount of connections that our server has to handle. Pushing systems, where the server notifies the client of an update, are much more efficient, have almost zero delay and don't result in a bunch of extra requests each time. HTTP is not designed with polling systems in mind. SPDY, an alternative protocol designed by Google, however has a feature that allows the connection to remain open. But SPDY will probably never be supported by Microsoft, and it still results in polling - which is really unnecessary for a chat.
Statistics: Posted by Demon — December 3rd, 2012, 10:32 pm
]]>