Pub/Sub using Redis, Node.js and COMET as transport - work in progress
JavaScript Erlang Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Simplified PUB/SUB with node.js:

- Binds into a redis channel called PUBSUB:COMET
- send everything received by this channel straight to connected users
- used COMET as transport

test with curl or any browser (some browsers as safari and chrome has a minimum buffer to fill before showing comet data)

start redis and run pubsub_comet:
$ node pubsub_comet.js

in another term
$ curl http://localhost:8080/subscribe

now publish messages to redis:

$ redis-cli

check curl's output and note that the connection still there.

also, use publisher.js to test a stream of search results from twitter to your users.

$ node publisher.js

Exploratory testbed using comet_test.js

comet_test.js has the same URL scheme, but exposes a /publish url so you can use curl as:

$ node comet_test.js

in other terminal
$ curl -X POST -d 'body=test' http://localhost:8080/publish to send data instead of redis.

if you keep getting too many open files error, try: 
$ launchctl limit maxfiles 1000000 1000000

In Linux, try:
$ sudo bash
# ulimit -n 999999

you can check with both strace (linux) and dtruss (mac os X) if your node.js binary is using epoll and kevent (kqueue) respectively. Select will balk on 1024 clients on mac.

The tests/ folder carries assorted testes made in different languages. Try opening 5k clients each time (simulating a ramp up).
chatter.js is intended to be a real chat simulation.

gleicon - 2010 - |