r/programminghelp • u/[deleted] • Aug 31 '18
How to monitor database updates in real-time for ~10k unique "ID's" via web sockets?
I'm not looking for a coding level help, but on a higher level.
I have a database containing millions of status values, each associated with a unique id, among other things.
I want to monitor these unique ID's (up to about ~10k at a time) and check it's status in the database. If the status changes, then I want to send that change over a web socket to update a client. Say the ID is a long and the status is a String.
How is something like this normally done in the real world without causing problems in the database?
How can you efficiently query 10k id's from a few million efficiently?
Is it as straight forward as a service that periodically queries the db for updates?
What's the real world situation for something like this as part of a critical system?
I can limit the number of clients to 10 or 20, but Ideally I'd like a few hundred. And each of those web sockets should be able to query a different batch of id's.
I'm not looking for a complete solution, I just want to know where I need to look to read what I need to consider when building this. What's the most efficient way to query the db, how to decide data limits, common mistakes to watch out for, etc....
2
u/Show_Me_Your_Stache Sep 01 '18
I would think whatever system is updating the database should instead call some kind of API that would then update the database and put a message into a message queue. You could then have a separate app listening for events in that queue, and it could fire off notifications to "anyone listening" on the web sockets. I might be wrong but I'd think you'd want to leverage the many to many aspects of MQs to help alleviate the pressures of trying to have hundreds of clients subscribing to 10k rows each for updates.