dongque4778 2012-09-11 13:10
浏览 38
已采纳

实时数据最佳实践和方法

Currently I have made a system where many screens are just lists, which update every N seconds depending on how many results per page the user has selected.

This is just a simple ajax call in a setTimeout loop. The main disadvantage I see with this approach I have used is that it is super inefficient in that it creates a lot of unnecessary network traffic and database calls.

The reason for this is that the data on the screen may change at any time, but the user needs to be aware if something new does come into the list so they can react to it as quickly as possible.

I was thinking of creating a Twitter style list where all you get is little notification at the top, which is just a COUNT of all the new items that you haven't seen. The user would then click on them to have the list refresh with the new items included.

The problem I have with this is that it is not truly a real-time list.

I have just started learning about Socket.io and NodeJS but I think it might take me some time to learn what I need to implement a real-time list that is efficient.

What are your thoughts?

  • 写回答

1条回答 默认 最新

  • doqrjrc95405 2012-09-11 13:58
    关注

    Take the time to learn Node.js and Socket.io. If you are looking for realtime between the browser and the server you can't really beat that combo. Socket.io is very efficient and will choose the best option the browser supports (polling, websockets, etc).

    The documentation for Socket.io is a little thin on good examples, but you can try their examples or the HowToNode article.

    You'll most likely want to put Express in there as well, it's a fantastic module.

    Good luck.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建