Push data from DB update to client without polling
I built a live auction platform primarily in php/JQuery/JS/MySQL many years ago. It basically had a back end where i would poll the DB for any bids, if there was/were i would push the data to all users via PubNub mechanism. If there were no bids after 5 seconds, i would close that lot off and move onto the next one and update all users via the same PubNub mechanism.
I am now redesigning the platform to be fully automated. I am looking to implement web sockets as the connection method. I want to implement a trigger which fires when a new bid comes in then pushes the info to all users. I also want to create a stored procedure which automatically checks if news bids have come in in the last 5 seconds, if not, close the active lot and set new active lot to n+1. This would be wrapped in an event which fires every second. That seems pretty straight forward.
My question is, once the stored procedure has determined that its time to move onto a new lot OR a new bid has come in, how can i push that information to the user?
Most of t开发者_运维问答he solutions out there seem to be 6-8 years old, and i was wondering if there is any way to do this without constantly polling from the users end, as this does not seem to be a scalable solution. Or does it?
I have looked at UDF/sys_exec() as a solution but a) a lot of people says its bad practise and its not designed to do that, and b) if i do execute a secondary .php script would there be a way to push the data to the user via the same websocket connection already established?
Thanks.
精彩评论