Fast polling using C, memcached, nginx and libevent
amix.dk
amix.dk
We wanted to do realtime notifications and polling isn't a way to do this. We tried different options and in the end wrote our own comet solution using JBoss Netty. Working with JBoss Netty was really great, but we hit perfomance limits on lots of open connections (100.000+).
At that time node.js was released and I did some experiments with it and found it it had great perfomance and very low memory footprint. I also had an university course on the V8 VM (by the actual Google team :)) so I was pretty interested in V8 and node.js at that time. I experimented more with this and eventually we rewrote our comet solution to node.js
Fast forward today we are still running node.js and processing many millions notifications each day. I would recommend digging into node if you are interested in building a scaleable notification system. Our comet implementation for node.js is under 1 KLOC.
Other posts you might be interested in:
* http://amix.dk/blog/post/19484#Comet-with-node-js-and-V8
* http://amix.dk/blog/post/19456#Plurk-Comet-Handling-of-100-0...
* http://amix.dk/blog/post/19489#Comet-long-polling-for-all-br...
A quick note is that we have implemented a custom java.nio solution and it had similar memory usages like Netty. It was much harder to code, so I would not recommend using java.nio directly, especially since there is little to gain in terms of perfomance/scalability.
is there any way you can post the code that you last used in production?How can we take posts like this seriously?
He provided recommendations to fix the mistakes instead of just dissing the whole thing. If you want people to write better code, share what you know.
Makes me wish Zed had a "Learn C the Hard Way" to complement what he's doing with Python.
I sure would like a 'hard way' courseware for C. (in addition to my trusty copy of K&R C for reference)
Thank you for calling attention to the second comment.
C is serious business.
(Incidentally, I've written event-driven programs with libev in both C and Perl. My load is usually so low that doing it all in Perl does not affect the number of requests I can handle, nor does it impact latency. The IO is the bottleneck; the article even says it only uses 2% CPU. Why risk insecurity when you don't know C and it doesn't even improve throughput?)
But it was very nice indeed that he takes time to review code voluntarily on blog comments.
In my opinion, having fewer requests to the server is better. But if someone can combat me on this, I'd really be interested in hearing another voice.