websockets, but have fallbacks • Good browser support (incl. old IE) • Should be usable from python • Does not require extensive changes in frontend • “As fast as it can be” 4 onsdag den 6. juni 12
on Chrome's JavaScript runtime • Uses an event-driven, non-blocking I/O model • Socket.io • One interface for all transport methods (sockets, polling, etc.) • Compatible with almost everything 6 onsdag den 6. juni 12
active community • Can be used from python without too much trouble • Most people know very basic javascript • More importantly, frontend engineers, knows javascript and can therefore contribute to the different browser-specific implementations. 7 onsdag den 6. juni 12
many datatypes • Can be used both as storage and as a queue • Implemented in many different languages • For the usage in this talk, any other queue could have been used as well. 8 onsdag den 6. juni 12
be notified in real time • From e.g. django we insert the new value into the queue • Node.js listens on the queue and emits any content directly to the browser via socket.io • This is btw. very fast! Redis Django Node.js E.g. Celery Browser publish subscribe publish subscribe 9 onsdag den 6. juni 12
redis = require('redis').createClient(); redis.psubscribe("socketio_*"); // Could be any pattern io.sockets.on('connection', function (socket) { redis.on('pmessage', function(pattern, channel, key){ socket.emit(channel, key); }); }); 10 onsdag den 6. juni 12
• Needs its own app, if hosted on an application cloud (e.g. heroku) • Recommended to expose the node server directly • But hey, it’s node.js, it scales! 14 onsdag den 6. juni 12
-> client • Currently no authentication between django and node. • Could possibly be solved by storing your sessions in redis and checking them on connection. 16 onsdag den 6. juni 12