I am writing a users-admin chat system (with logged users) where an admin must detect online users. I don't have any experience with this sort of system and I need your advice.
I have created following tables:
users (user_id, last_active, login, password)
chat (chat_id, user_id, read, dir, msg, posted_on)
history (history_id, user_id, dir, msg, posted_on)
Every 7 seconds I am doing an asynchronous request with jQuery or sending a message and every time on the server side I do the following operations:
if(isset($_POST['msg_send'])){
//check admin(user) online statuse:if admin(user) online insert msg to chat and history.
if admin(user) isn't online, echo "admin not online"
return;
}
//get message from chat ;
//update chat_table;
I am wondering: if I perform this operation for every request, will it be a big hit performance-wise? If so, can you suggest another option?