[Answer]-Django continuously sending data to clients based on events

1👍

It would require a huge amount of effort to get django to do this without impossible memory requirements, and even then, it would still be harder than it’s worth, so i’ll present some alternatives instead.

You might see if django-socketio would help you do what you want, however it seems like it’s pretty far out of date.

Last time I had to push real-time events from a django app to the client, I used a rabbitmq server to deliver packets of messages to queues that connected to a very thin server I built using tornado, with a basic long-polling approach. That worked, but it ended up being a complicated system, with a lot of moving parts that isn’t the most maintainable.

More recently when I’ve had to do things with events being pushed to the client, I used node.js + socket.io, which is a lot simpler to get working (at least if your not using the full routing power of rabbit, which I was not.

If you want to use that setup alongside django, you run a seperate node.js server alongside however you’re serving django, and put HAproxy in front of the whole stack, to avoid cross domain issues. The only issue remaining would be how to connect between the node server and your django app, which could be HTTP calls on a private port, a redis pub/sub setup, some sort of messaging setup like rabbit or zeromq, or anything else you dream up.

👤JeffS

Leave a comment