High Performance Web Socket Server
The Web still has a long way to go to fulfill its potential for distributed applications. HTTP and JSON have proven their worth, but can overload servers trying to handle large number of simultaneous connections. A promising new technology is Web Sockets which allows bidirectional messaging over a single TCP connection. The connection is set up very much like HTTP, and can use the same ports for easy passage through firewalls, but once established, both ends are free to send messages at will without the overhead involved in using HTTP.
Web Sockets is supported by a variety of browsers including Firefox 4, Google Chrome 4, Opera 11 and Safari 5, even though the protocol is still evolving. The IETF BiDirectional or Server-Initiated HTTP (hybi) Working Group is defining the protocol, whilst the W3C Web Applications Working Group is specifying the Web Sockets API for use by web page scripts.
Spurred on by this, I have developed an open source implementation of a Web Sockets server with a view to exploring a variety of collaborative real-time applications. The server is written in C and based upon the epoll system call first introduced in Linux 2.6. The server runs as a single process with one thread per CPU core. This architecture was chosen to enable the server to support thousands of simultaneous connections. A potential down-side is that the server-side code for applications has to be written in C and compiled to dynamically loaded libraries managed through a configuration file. This is still a work in progress, and I have recently completed adding support for JSON. Coming up is support for TLS and Web Sockets Secure (wss) connections, and preparing the server for its initial release. If you have any suggestions for naming the new server and what features you would like to see, please let me know!
Although the design of web sockets is still under discussion, it is encouraging to see the range of server implementations now available. Some examples include Tornado (python), Sprocket, Mojolicious (Perl), em-websocket (Ruby), and Node (server-side JavaScript). If you know of others please let me know.
As far as I understand, Firefox 4 may not be shipping with Websockets on by default, due to the security issues with the outdated draft it implements (currently being discussed in the WG).
What is the status of this? I started writing what sounds like exactly the same thing with the same goals, no point in duplicating work unless this project is abandoned?
A quick status update: I have now added support for TLS together with a growing subset of HTTP 1.1, and am currently focusing on multi-user editing of HTML/XML documents via HTTP and Web Sockets. The server should be available publicly by the middle of the year, but if you want a preview please let me know. Moreover, if you are interested in helping prepare the server for launch, e.g. testing and documentation, that would be even better!
Although, we are waiting on the HyBi WG to finish the protocol design, the current browser implementations of Web Sockets are very much adequate for developing and testing new collaborative applications. The future for Web Sockets is bright!
"If you know of others please let me know."
Union Server recently added WebSocket support.
http://www.unionplatform.com/
http://www.unionplatform.com/?page_id=2954
any news on your server? where will you be posting it?
Hey,
I am interested in helping you develop this project. Can we talk more about this and your current status?
Thanks.
Hi Dave,
are there any further updates?
I am interesting in your project. If "only" the implementation of the changing websockets specification is the too much time consuming part of your project, you could consider to make use of the well working libwebsockets:
http://git.warmcat.com/cgi-bin/cgit/libwebsockets
I am very curious about your server application. Would you show me a preview? I could do some comparison benchmarks to another c-written server like nginx, gwan and so on.
regards
Sorry for being so quiet on this. I have been busy on other things but plan to come back to this shortly, now that the web sockets protocol and API specifications have stabilized, so it is timely to upgrade the server to support the new version of the protocol.
My W3C Team colleagues asked me to look into providing a bridge between the web sockets server and the existing W3C IRC server which we use extensively together with our teleconference bridge Zakim. Such a bridge would allow for a smooth gradual transition from IRC to a web sockets based meeting service.
Early this year I developed a multilingual chat module using the web socket server. This allows users to indicate which languages they understand and have messages in other languages translated into their preferred language. The translation is done client-side using either the Google or Microsoft translation services. I now want to reimplement this to make it easier to provide a bridge to IRC and Jabber-based chat services.
A further off goal will be to support the ideas of the HTML + Speech Incubator Group which propose using web sockets to support cloud-based speech and natural language processing. However, well before that I need to put the server up on code.w3.org, something that is long overdue.