Friday, October 30th, 2009
>The following is a guest post. If you have something to say to the Ajaxian community, please feel free to either link us to your work, or give us a guest posting that goes into detail! Contact us.
My name is Jerod Venema, and I’m excited to write to you about our new Comet server for the Microsoft stack – WebSync. It is written in 100% managed C#, and uses IIS to reach incredibly high user concurrency. Despite being written in C#, we’ve made it easy to integrate other languages as well by pre-building client libraries and allowing generic HTTP requests to send messages.
There are many challenges in getting a Comet server to operate efficiently in any language, and the .NET environment delivers its own set of unique challenges. One of the biggest challenges we faced was how to make IIS “play nice” when scaling to tens of thousands of concurrent HTTP connections and message transactions. A great deal of time was spent minimizing the memory footprint (even to the point of lazy object construction), optimizing libraries, and digging through pages of profiler results. Multi-threading reared its ugly (but powerful) head on more than one occasion as we sought to take maximum advantage of multiple CPU cores while keeping locking and concurrency issues to a minimum. We even ended up writing a new lock-free data structure similar to a linked queue that allows us to perform multiple-writer add/remove operations – very helpful when dealing with large lists of clients and messages. Once all was said and done, we tested on a $500 Acer desktop and saw over 30,000 concurrent users and 25,000 messages per second. (We were pretty pumped when we saw some of those numbers coming through!)
We also spent some time on making it easy to integrate into non-browser applications. One of the really neat features is the ability to publish data via a simple GET/POST request, so it can integrate into any application that can make a web request, regardless of the language. If you’re writing in PHP or .NET, we’ve made life even easier by writing publishers that wrap up the creation and invocation of the web request into single method calls.
Oh, and we’ve got a hosted version too (WebSync On-Demand), so people with smaller sites who don’t want the cost of hosting their own Comet server can still get all the benefits of a full Comet solution. For the On-Demand solution we’ve also implemented request proxing, which allows developers to direct the low-impact publish and subscribe requests to their server first, so they can pre-process any incoming messages (to add authentication, save messages to a database, etc). And again, for PHP or .NET users, it’s a one-liner to implement.
Posted by Dion Almaer at 6:02 am