dongnanke4106 2010-11-29 19:06
浏览 66
已采纳

存储聊天应用程序的“用户在线”列表(php / ajax)

I have several chat rooms. Currently, I store the list of chat users in a php variable. If a user enters or leaves the room, the user's name is added/removed from that list. To make this storage persistent, I use memcached. To update the status of the chat room and send the user list to all users in the chat room, I use periodical ajax requests that fetch the user list into the browsers of the users who are in the chat.

It works okay. But I doubt that sending the whole list of chat users to everybody every XX seconds is a good idea if there are a couple of hundred people in the chat.

How are chat rooms usually dealing with this problem?

  • 写回答

6条回答 默认 最新

  • douzi8548 2010-11-29 19:11
    关注

    Have no idea how they do, but here are some ways you could. Remember to measure before and after you optimize.

    • Version the list. Don't get the full list if you have an up to date version.
    • Diff the list. Send only the updates since the last update.
    • Log this list. Cache or push updates as new events occur.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度