实时数据最佳实践和方法

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?

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.