I am trying to build a MySQL, PHP, Ajax based personal messaging system.
There is one table for all messages - msghistory
, which looks like that
And another one for users' last message check date records - chkdate
.
The system works like this:
When user signs into page, page fires Ajax autocheck. Ajax calls php in every 10 sec. PHP side checks for new messages by user id. At first checks chkdate
, then checks msghistory
: If there are no message after last check date then system will not notify user, else will notify about this
I think this way will load server heavily, if there are 1000s of users. I wonder if explained above way is optimal? if not, what do you think about this, which way is better?