Check the article link below (and this Facebook blog post) for some details on how Facebook engineers addressed the challenge
Facebook may be about to suck up even more of your time. Two weeks ago a feature rolled out that I'm told many users may not have noticed, but that is predicted to soon have them interacting with each other more on the the social network.
That feature was instantly updating comments, and it turns every piece of content on Facebook into an instant messaging chat room. Any time you add a comment to, say, a photo or status update it will now appear instantly in front of anyone else looking at that same page.
Switching to live updating may seem a small change from a user's perspective. But the engineering decisions Deeter and colleagues had to make illustrate how complex it is to operate a site with more than half a billion users.
An excerpt from the Facebook Live Commenting post:
So we needed a push-based approach. To be able to push information about comments to viewers, we need to know who may be viewing the piece of content that each new comment pertains to. Because we serve 100 million pieces of content per minute, we needed a system that could keep track of this "who's looking at what" information, but also handle the incredible rate at which this information changed.
Write Locally, Read Globally
Storing these one-to-one, viewer-to-content associations in a database is relatively easy. Keeping up with 16 million new associations per second is not. Up until this point, Facebook engineering had built up infrastructure optimized for many more reads than writes. But now we had flipped the game.