I am trying to make a facebook like conversation system and I have pretty much succeeded. Now there are a few confusions. When the message is sent from one user's end, ,I can simple use ajax to insert it into database and have the callback function append the last message at the bottom of list of messages that are being displayed.
However, on the receiver's end, I have to display the message that is the most recent in database (sent by the other user). One way I can think of is keep checking the table containing messages for updates after a certain interval of time, and get over it.
But, in a hypothetical situation, in a hypothetical universe, where my site actually has tens of thousands of users, and each of them have like 50 conversations in their inbox. I can only imagine every few seconds the database being queried a million times which will be too much of a burden and will slow down everything. Now, My question is, is there someway that the web server on the database update 'notify' the webpage to refresh instead of the web browser requesting new page after a specific interval. I'm not a professional web developer or something and have tried googling already. The nearest I've got to is this WEbSOcKeTS thingy, which I'm unsure of.