I'm building a stock ticker that requires continuous real-time updates. JavaScript on the client talking to .NET WCF 4.5, which introduced support for WebSockets.
Users' feeds vary significantly. For example, many users follow popular big-caps like FB, GOOG and MSFT, but each user follows many other "niche" stocks that may be unique to him.
We all know there are a few options for refreshing the browser in real-time.
Polling. Pros: Easy implementation. Cons: Doesn't scale, primitive, wastes bandwidth and cycles.
Long-polling. Pros: Efficient, scalable. Cons: Antiquated?
WebSockets. Pros. Efficient, scalable. Cons: None I can think of as most modern browsers support them as per caniuse.com.
Would anyone pick anything other than 3.?
Assuming I go with 3., how are the server's open connections kept track of? For example, if we design such that we keep a pool of FB "followers" (i.e., client connections interested in FB's price changes) so that we know whom to update when a price change occurs, how is this pool maintained? By a service that runs constantly in memory? Also, if a FB follower closes her browser, does the service need to catch this event and update FB's follower pool? This is where I get fuzzy quickly.