dongque4778
dongque4778
2012-09-11 13:10

实时数据最佳实践和方法

  • node.js
  • socket.io
  • php
  • mysql
  • ajax

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条回答