Reputation: 380
I have a jQuery dataTable, with lots of data(10000+ rows), which can be used/updated in the real time from lots of users and I need that table to be refreshed and up to date all the time. I've tried with Ajax calls on 1 second, and I figured that that's not good, since every user is sending Ajax request every second * 50 or more users, and I think that there must be a better solution. I've been thinking to use Django Channels, or something similar(?) and i was wondering is that possible? Basically I need to set up some kind of listener on the model(database), and to pull the new data on change(that is almost every second). I would love to here an opinion from someone who has more experience than I do. Thank you in advance.
Ps. I've been told to use web sockets for that.
Upvotes: 4
Views: 1146
Reputation: 2408
In short yes web socket would be the suggested way to do this.
If all the updates to the models that you need to subscribe to are being made through Djangos ORM.
I would suggest looking into using (or be inspired by) DjangoChannelsRestFramework as a starting point for subscribing to multiple models in your db.
This library is set up to let you subscribe to multiple object types over a single web socket connection and get ws messages whenever they objects change. It also provides some tools to let you re-use your existing DRF views over the web socket.
Disclaimer: I am the author of the DjangoChannelsRestFramework.
Upvotes: 2