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条)

报告相同问题?

悬赏问题

  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥15 小红薯封设备能解决的来
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答