Try
↑ ↓ move↵ openesc close

Interview prep / News feed

Mid · News feed · System design interview question

How should a feed be paginated?

Sketch your own answer first, then compare it with the one below.

A strong answer

Use a cursor, not a page number. New posts arrive at the front, so a page number shifts and the next page repeats or skips items.

The cursor names the last item the reader saw, as a time and an id, and the next request asks for older items. Include the id because two posts can share a time. Keep the cursor opaque so you can change it. Refresh asks for items newer than the newest the client holds.

Sources

Learn it by running it

The design a news feed lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms