Ever since Twitter and Facebook debuted their feeds in 2006, the model of continually streaming updates has come to define how we consume information. We’ve grown accustomed to a world in which data flows by us, letting us dip into the stream whenever, wherever, and however we want. But feeds have really taken off in the mobile era, with hundreds of apps overcoming the limitations of the small screen by presenting information as a swipeable stream. To Facebook CEO Mark Zuckerberg, it’s obvious: “Every new product that wants to build engagement bases its design on feeds.” And no one has mastered the art of feed design like Twitter and Facebook. Both companies have endlessly experimented, devising techniques to deliver the stories and updates users care about—and avoid overwhelming them with noise. The result is a series of computations that are as crucial to the information industry as Google’s search algorithm. Here’s a peek under the hood at what went into building Twitter’s and Facebook’s feeds—and how they keep you glued to the screen.

Long before Dick Costolo became CEO of Twitter, he fell in love with the way it presented the world to him. It wasn’t like email, just stacking up in his inbox, and he felt liberated by it. “It’s here and it’s gone and it’s all moment to moment,” he says. “Some of it I’ll have time for, and some of it washes down the river. It’s a much more comfortable way of consuming information.” Under Costolo, Twitter has been much more active in devising signals to refine its product and offer its members ways to unearth and organize the updates that are important to them. In addition to the Home timeline, Twitter has added alternative timelines and other features that help people expand and fine-tune their connections. These include Discover, a feed that tries to present tweets that will appeal to you, and Activity, which highlights the tweets that people you follow are interacting with.

In Zuckerberg’s view, streams are like television—a compelling, satisfying flow that doesn’t make demands on you. But unlike with television, everyone’s programming is unique. “On the Internet, of course, things should be personalized to your interests and the things you care about,” he says. At any moment, the News Feed team is testing dozens of possible tweaks to the story selection and ranking algorithms for that programming. In addition, Facebook surveys users directly. “We’re testing a lot of things every day to figure out what’s going to make the most engaging feed,” Zuckerberg says. “We use quantitative metrics that measure likes and comments and clicks and shares and other activities to see if a story is good, but we also have qualitative systems so that people can reorder a feed to tell us what they thought were the most important things.”