Checking for new message using AJAX and PHP. Server overload?

Thank you for your help. I did it another way. I believe it won’t overload in the future when there will be more users.

I will try to explain it, but if anyone will need help with the code I’m willing to help.

In the “send_message.php” file, after database insert, I added a piece of code that creates a new empty text file with receiving user id as a name.

In the “receive_user.php” file, after database update (message read), I also added a piece of code, but this one deletes that same text file from above.

Finally, the PHP code used by AJAX checks if text file with logged in user id as filename exists. If it does, it echoes 1.

As you can see, there’s no constant database checking.