'Realtime data update to the client using Websocket in node js

I want to send ws message to the client when my sql sever database table values updated or new row inserted (real time data) for that client. how can I achieve this. I'm using Node js and Mssql for DB. what I tried before was checking every second to DB and sending the records to the clients. But the problem is when more users connected I'm getting database timeout error. Why because I'm checking db for every users every seconds. What can I do now how can I solve this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source