1

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?

1
  • 4
    You need to accept answers to your questions (as has been explained to you before in other questions). Until you go back to your old questions, I won't be helping you here. Sorry, but there is no free lunch and people have spent a lot of time helping you in the past with very little or no thanks from you. This is a matter of courtesy that you need to perform in order to be a useful member of this community. Commented Feb 7, 2011 at 20:48

1 Answer 1

1

Although this probably shouldn't be a massive performance hit depending on how active the chat room is it is worth considering caching the chat room.

For example you could cache any of the data that you are receiving from the database and you could cause those caches to expire whenever a user logs in or posts a new message.

There are also a number of ways of caching. Two examples are file based caching or using memcached.

Hope this helps Daniel

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.