A few years ago, backend engineering interviews followed a fairly predictable script: open a blank editor, solve an algorithm puzzle or live-coding prompt until the test cases turned green, then wrap up with a brief chat about your past projects.
That balance has been shifting quietly.
Coding rounds have not disappeared—teams still need to know you can write, read, and debug clean code. Yet when almost every candidate now works alongside AI coding assistants that can scaffold handlers, draft SQL queries, and generate unit tests in seconds, typing syntax from memory is no longer the clearest signal of engineering maturity.
More interviews now spend their heaviest weight on something a quick prompt cannot reliably substitute: how you think about systems as a whole.
An AI assistant can write a POST /like endpoint in five seconds. What it will not automatically catch for you is whether that endpoint will lock a single database row under a viral spike, or how to ensure a user still sees their own like and comment appear immediately after tapping the button.
To make that shift concrete, let’s walk through a classic system design prompt that shows up often in interviews today: designing a Twitter-like timeline where posts can be liked and commented on—both by other users and by the author themselves.
Why system design carries more weight now
Modern software work looks less like isolated typing and more like architecture, verification, and trade-off management. We are no longer bottlenecked by how fast boilerplate gets written; we are bottlenecked by whether an engineer spots unintended consequences before a design reaches production.
When interviewers give you a system design problem, they are rarely grading you against one “perfect” textbook diagram. They are watching for habits that come from real engineering judgment:
- Do you clarify scale and constraints before drawing boxes? A system serving ten thousand daily users should look very different from one serving tens of millions.
- Can you locate your own bottlenecks? Where does the database lock? Which cache gets hammered? Where do queues back up?
- Can you defend trade-offs plainly? Why accept a few seconds of eventual consistency for a public like counter while keeping the like record itself strictly unique?
Those instincts are built by maintaining live systems, reading failure postmortems, and thinking through edge cases. That makes system design a much harder signal to fake.
Case study: A Twitter-like timeline with likes and comments
Imagine the interviewer opens with:
“Design a simplified Twitter-style timeline. Users can publish posts, follow others, view their home timeline, and like or comment on posts—including their own.”
Resist the urge to immediately draw Kafka clusters and microservices on minute one. Start by narrowing the problem down.
Step 1: Align on assumptions first
Four quick clarifications usually set a solid boundary:
- Core actions: create short text posts, follow accounts, load a home timeline (posts from followed accounts plus your own), and like or comment on any post (someone else’s or your own).
- Traffic shape: heavily read-dominated. People refresh timelines far more often than they publish posts.
- Consistency expectations: when you publish a post, like a post, or leave a comment, you should see it right away. Global counters (
like_count,comment_count) across everyone else’s feeds can lag by a few seconds (eventual consistency). - Interaction rules: one user can like a given post at most once (tapping again unlikes), while comments can be added multiple times—and both rules apply equally whether the user is someone else or the post author.
Once those assumptions are on the board, every technical choice has a clear reason behind it.
Step 2: Core data model
For structured entities that benefit from constraints and predictable queries, a relational database like PostgreSQL remains a very dependable source of truth:
users:id,username,display_name,created_atfollows:follower_id,followee_id,created_atwith composite primary key(follower_id, followee_id)posts:id,author_id,content,like_count,comment_count,created_atlikes:post_id,user_id,created_atwith a unique constraint on(post_id, user_id)comments:id,post_id,author_id,parent_comment_id(nullable, if threaded replies are supported),content,created_at
Two small schema details here often separate surface-level answers from experienced ones:
First, the unique constraint on (post_id, user_id) in likes. Without enforcing uniqueness at the storage layer, a flaky mobile network retrying a request can easily produce duplicate likes. With that constraint—paired with ON CONFLICT DO NOTHING or clean toggle semantics—every like action becomes idempotent, whether it comes from another user or from the post owner.
Second, timeline and comment pagination. Avoid OFFSET on fast-moving feeds: as new posts or comments arrive, row offsets shift and users see duplicates or skipped items. Use cursor-based pagination ordered by (created_at, id) or time-ordered IDs (such as Snowflake-style IDs).
Step 3: The classic timeline dilemma — Push vs. Pull
This is the heart of the interview question. When a user opens their home feed, how does the backend assemble the latest posts from hundreds of accounts they follow?
There are two foundational strategies, each with a clear cost:
| Strategy | How it works | Strength | Main bottleneck |
|---|---|---|---|
| Fan-out on Write (Push) | When Alice posts, an async worker pushes post_id into the cached timeline list (e.g., in Redis) of every follower. |
Reads are very fast: fetch recent post_ids from cache and hydrate post details. |
The celebrity problem: if Alice has millions of followers, one post triggers millions of cache writes. |
| Fan-out on Read (Pull) | Nothing is precomputed on write. When Bob opens his feed, the service queries recent posts from everyone he follows and merges them. | Writes are cheap and instantaneous; no duplicated feed lists. | Reads become expensive if Bob follows hundreds of active accounts. |
In practice, the strongest answer in an interview is a hybrid fan-out:
- For regular accounts with moderate follower counts, use fan-out on write via background workers pushing
post_idinto followers’ Redis timeline caches (such as aSorted Setor cappedList). - For high-follower accounts (celebrities, news outlets), skip pushing to millions of timelines. Keep their recent posts in a fast per-author cache and merge them at read time (pull for high-fan-out authors only).
- What about your own posts? Whenever you publish a post, write its
post_idstraight into your own cached timeline (and return the created post directly from the write endpoint). That guarantees you never refresh your home feed and wonder where your own post went.
Step 4: High-level architecture
Put together, the end-to-end flow looks clean and modular:
┌──────────────────────┐
│ API Gateway │
└──────────┬───────────┘
│
┌────────────────────────┼────────────────────────┐
▼ ▼ ▼
┌─────────────────┐ ┌──────────────────┐ ┌──────────────────────┐
│ Timeline Read │ │ Post Service │ │ Interaction Service │
│ Service │ │ (Create / Get) │ │ (Like & Comment) │
└────────┬────────┘ └────────┬─────────┘ └──────────┬───────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌──────────────────┐ ┌──────────────────────┐
│ Redis Cache │ │ PostgreSQL │ │ Message Broker │
│ (Timeline IDs, │ │ (Source of │ │ (Kafka) │
│ Post & Counts) │ │ Truth) │ └──────────┬───────────┘
└─────────────────┘ └──────────────────┘ │
┌─────────────────────────┼──────────────────┐
▼ ▼ ▼
┌─────────────────┐ ┌────────────────┐ ┌──────────────┐
│ Fan-out Worker │ │ Counter Worker │ │ Notification │
│ (Update Cache) │ │ (Batch Update) │ │ Service │
└─────────────────┘ └────────────────┘ └──────────────┘
Step 5: Designing likes and comments without melting the database
The second half of the prompt—supporting likes and comments from both others and yourself—is where interviewers probe concurrency, caching, and user experience.
1. Handling likes at scale
A common rookie trap is running both of these statements synchronously in a single transaction on every tap:
INSERT INTO likes (post_id, user_id) ...UPDATE posts SET like_count = like_count + 1 WHERE id = ...
At low traffic, that works fine. But if one post goes viral and attracts thousands of likes per second, every transaction contends for a row-level lock on that single row in posts. Latency spikes, connection pools fill up, and the database becomes the bottleneck.
A cleaner design separates recording the action from updating the aggregate counter:
- When any user (another person or the post author) taps Like, the Interaction Service records the unique
(post_id, user_id)pair and updates the per-user state. - It emits a
PostLikedorPostUnlikedevent to a broker such as Kafka. - A Counter Worker aggregates events over short windows (for instance, every few hundred milliseconds or seconds) and performs batched increments against Redis and PostgreSQL.
Now for the crucial UX question: what happens when you like your own post (or someone else’s) and immediately refresh?
This is where read-your-own-writes matters. When hydrating posts for viewer_id, the Timeline Read Service checks whether viewer_id has liked those post_ids—via a fast Redis lookup or a batched query (WHERE post_id IN (...) AND user_id = viewer_id). That way, liked_by_me: true is immediately accurate for the person who tapped the heart, even while the global like_count catches up asynchronously in the background.
2. Handling comments cleanly
Unlike likes, comments carry user-written text, ordering, and edit/delete lifecycles:
- Storage & pagination: Comments live in
commentsindexed on(post_id, created_at DESC, id DESC). When loading a post, fetch comments in pages using cursor pagination rather thanOFFSET. - Self-comments vs. others’ comments: Both go through the exact same write path. When you comment on your own post (for example, adding context or replying in the thread),
POST /commentspersists the row and returns the full comment object in the response so the client renders it immediately without waiting for async workers. - Comment counts: Like
like_count,comment_countcan be incremented asynchronously under heavy bursts, while hot posts can cache their first page of recent comments in Redis and invalidate or prepend on new writes.
3. A subtle detail interviewers love: self-notifications
If self-likes and self-comments use the same pipeline as everyone else’s interactions, an observant interviewer will almost certainly ask: “Does that mean the system sends you a push notification saying you liked your own post?”
Of course not.
Keep the core storage and counting rules uniform—a self-like and a self-comment are valid data records and count normally. Handle the filtering cleanly inside the Notification Service: when consuming PostLiked or PostCommented events, check if actor_id == post_author_id. If they match, skip sending a notification to the post owner (unless the comment is a reply to another user’s comment under your post, in which case notify the parent comment’s author).
That keeps your data pipeline simple and your notification inbox sane.
What actually sets candidates apart now
In the AI era, engineering value is less about how quickly you can recall syntax without documentation. Coding fluency still matters—you cannot review AI-generated code responsibly if you do not understand what good code looks like.
Yet the signal that increasingly decides senior and mid-level offers sits one layer higher:
- Tracing data end to end—from a tap on glass through APIs, caches, databases, and background workers.
- Asking early where things break at 10x traffic—row locks, celebrity fan-out, cursor shifts, and cache stampedes.
- Being honest about trade-offs—knowing that every speed gain introduces an invalidation or consistency cost you have to manage.
AI makes producing the implementation faster than it was five years ago. Deciding whether the architecture will survive its first traffic spike—or collapse under a single viral post—still belongs to the human drawing the system.
Comments