Next-generation Web applications will no longer need to describe interactive communication by serving lots of mini-documents over HTTP. They will instead take advantage of the HTML5 Web Sockets protocol, which is designed to deliver the performance of a bi-directional, full-duplex TCP connection, while maintaining compatibility with the HTTP constraints of the Web. Using this approach elevates the communication capabilities of a Web Socket application to rival that of traditional desktop and modern mobile applications.
The Web Sockets protocol is optimized to reduce communication overhead to a minimum. After the initial HTTP-compatible handshake, each message payload transferred via Web Sockets contains only a very small number of additional framing bytes, usually just 2 bytes. Comparing this to the approximate 1,000 'overhead' bytes in a typical HTTP request-response yields significant gains by a factor of 500. The latency characteristics of Web Sockets are also impressive. The maximum latency of message delivery from Web tier to browser can be reduced by a factor of 3 for Web Sockets compared to the HTTP request-response communication approaches used by Comet, Reverse Ajax or Ajax Push.
Unlike the HTTP request-response paradigm, Web Sockets represent a connection-oriented architecture, which means that connections stay open between message transfers until they are explicitly closed by the client. Clearly, leaving a connection open has the potential to create additional overhead on the server, but this occurs only when the client anticipates server-initiated communication, such as subscribing to a stock ticker feed. The optimized Web Sockets wire protocol lends itself to highly scalable Web Socket server implementations, where the transfer of each message consumes minimal resources, allowing many thousands of connections to be handled on a single server. Kaazing has successfully demonstrated one million connections to our Kaazing WebSocket Gateway to illustrate this point.
Enterprise-class Web application features such as high availability and disaster recovery are easier to deliver via a Web Sockets based architecture, as Web Sockets are connection-oriented; making it very clear if/when a Web Socket becomes disconnected. This creates a straightforward approach to determine exactly when additional work might be required to recover from connection loss. As a result, there is no need to perform repetitive tasks on the server in preparation for a potential connection failure that might never occur. This provides a resilient architectural approach that delivers rapid recovery from network outages, while maintaining the scalability strengths of Web Sockets under normal operations.
Web Sockets is not simply a better version of Ajax, but instead is a quantum leap in browser-based communication. Web Sockets represent a fundamental shift in Web application architecture, eliminating the need for application glue code in the Web tier. With Web Sockets, next-generation Web applications will consist entirely of highly cacheable static resources such as HTML, scripts, styles and images which are served over HTTP, while bidirectional, full-duplex communication is provided by Web Sockets. Web Sockets represents a best-of-breed approach to Web applications, replacing the existing work-around approaches that have been attempted by various plug-in technology vendors using raw sockets. The current approaches have had limited success due to problems traversing HTTP-constrained firewalls and proxies that are a fact of life for any enterprise client deployment, and are increasingly common for end-user deployments where anti-virus programs may include a transparent HTTP proxy.
By effectively delivering a Web-compatible TCP stack to the browser, HTML5 Web Sockets represents a massive step forward in Web communication, but this is only the beginning. We can now extend the reach of traditional server protocols to the browser using Web Sockets. For example, extending the reach of an enterprise messaging system protocol such as XMPP, AMQP, or even a JMS vendor protocol becomes entirely straightforward. This changes the Web application programming model from coding against HTTP document APIs that require a programmatic Web tier such as Java Servlets, to coding against first-class protocol clients that have the same capabilities as any other desktop or mobile client using the same protocol to communicate directly with the enterprise messaging system.
If we consider that traditional desktops have the full power of the Internet at their disposal because they can use any protocol they like to communicate, and also that Web browsers are limited due to the HTTP constraints of the Web, then it's an obvious conclusion that Web Sockets bring back the full power of the Internet to Web browsers and Web architects alike.