This question already has an answer here:
- PHP - Real time notification system- supporting all browsers and devices 1 answer
- Real time notifications on shared hosting (PHP, MySQL, Yii) 3 answers
- SSE or long polling for real time notifications on shared hosting? [closed] 1 answer
- How to get notification with Ajax and PHP when user submits data in mysql? 1 answer
- Adding Node.js (for real-time notifications) to an existing PHP application 2 answers
I'm trying to understand how to correctly implement the notification system on the website, when adding a comment or post to the database the user has a window with a message about it. I know that this can be done with the help of the WebSocket, and Server-sent events, and long polling. I tried to find examples of implementation of this on PHP and fell into a stupor. The main aspect of event handlers (whether Long Polling or SSE) is checking the change in the database in an infinite "while (true)", but in my opinion, if in an infinite loop it is constantly polled by database requests, sooner or later, with more users, the database not stand the load. This is the question of how to correctly implement these notifications and similar things from the DB + Long Polling (Websocket, SSE) without endless polls to the database? Maybe I'm missing something in this moment. I also heard about the method of creating a separate event table, which is also constantly polled, and if there are entries, the server sends the message and deletes the record from the database, but again, these are endless requests to the database.
Aucun commentaire:
Enregistrer un commentaire