Sub topic 1
Start with the problem, not the boxes
Most weak system designs fail before the first box is drawn. The designer hears "design a URL shortener" or "design a news feed" and starts placing load balancers, caches, and databases. The diagram looks like a system, but nobody can say what it is for. This chapter explains why you should frame the problem first and gives you a short routine for doing it.
Prerequisites
This chapter assumes you can:
- Describe the client-server model and how a web request travels from a browser to a server and back.
- Read and write simple HTTP APIs, and explain what a database does.
- Read short Python snippets. Later chapters use Python for small calculations.
You do not need to know any specific cloud service or database product.
Why framing comes first
An open-ended design problem is deliberately underspecified. "Design a photo sharing service" could describe a weekend project with 200 users or a global product with hundreds of millions. The right architecture for one is the wrong architecture for the other.
Framing is the work of turning a vague prompt into a problem you can solve. It answers four questions:
- Who uses the system, and what are they trying to get done?
- What must the system do, and how well must it do it?
- How big is it, now and later?
- What is out of scope?
Drawing boxes before answering these questions has a predictable cost. You pick components for a problem you imagined, then defend them against requirements you discover later. Changing a design late is slower and more awkward than asking questions early.
The common failure: solution-first design
Solution-first design starts from a favorite architecture and fits the problem to it. Typical symptoms:
- A message queue appears in the diagram, but no one can name the work that needs to be asynchronous.
- The design shards the database on day one, though the stated data fits on one machine.
- The design is "highly available" with no number attached, so no one can tell whether it succeeded.
- The discussion jumps between topics, because there is no agreed list of what the system must do.
Each of these adds cost (money, complexity, operational burden) without tying back to a need. A box earns its place by solving a stated requirement.
A framing routine
The routine below takes a few minutes in an interview or a design review, and longer on a real project. Each step produces something you write down.
Step 1: Restate the problem in one sentence
Say what the system does and for whom. Keep it free of technology.
Weak: "We need a distributed key-value store with a cache."
Better: "Users paste a long link and get a short one. Anyone with the short link is redirected to the original."
If you cannot write the sentence, you do not yet understand the problem. If two people write different sentences, you have found a disagreement worth resolving now.
Step 2: Identify the actors and their goals
List who interacts with the system. An actor can be a person, another service, or an operator.
For the URL shortener:
- A creator submits a long URL and receives a short one.
- A visitor opens the short URL and is redirected.
- An operator monitors the service and removes abusive links.
Actors matter because each one produces different traffic. Creators write. Visitors read. Operators need visibility. Missing an actor often means missing a whole feature or a whole class of load.
Step 3: Ask clarifying questions
Good questions narrow the design space. They are specific and each has an effect on the architecture. Compare:
| Vague question | Sharper question | What the answer changes |
|---|---|---|
| "How big is it?" | "Roughly how many daily active users, and how many reads per write?" | Capacity, caching, partitioning |
| "Should it be fast?" | "What latency is acceptable for a redirect at the 99th percentile?" | Caching, data placement |
| "Does it need to be reliable?" | "Is losing a link acceptable? Is a few minutes of downtime acceptable?" | Replication, backups, consistency |
| "What features?" | "Can links expire? Can users choose custom aliases?" | Data model, uniqueness checks |
Prompts that reliably surface hidden constraints:
- Read-heavy or write-heavy?
- Does the data need to be strongly consistent, or is slightly stale data fine?
- Is this global or in one region?
- Is there a deadline, budget, or existing system we must integrate with?
Step 4: Separate what from how well
Sort what you learned into two lists. This sets up the next chapter, so only the idea is introduced here.
- Functional requirements describe behavior: "create a short link", "redirect a visitor".
- Non-functional requirements describe qualities: latency, availability, durability, consistency, cost.
Functional requirements tell you what the API needs. Non-functional requirements usually decide the architecture.
Step 5: Draw the boundary
State what you will not design. "We will not build analytics or a user-facing dashboard. We assume authentication already exists." A boundary protects you from endless expansion and makes your later trade-offs defensible.
How the process fits together
The chapters of this tutorial follow a fixed order. Framing feeds everything after it.
The dotted arrow is important. Framing is not a one-time gate. When a deep dive shows that a requirement is expensive, you go back and discuss it. That is the process working as intended.
A worked example
Suppose the prompt is: "Design a notification service."
A solution-first response starts with "We need Kafka, workers, and a database." A framed response starts with questions.
One-sentence restatement: "Other services in our company send a notification request, and the system delivers it to the user by push, email, or SMS."
Actors:
- Producer services that request notifications.
- End users who receive them.
- Operators who investigate delivery problems.
Clarifying answers (assumed for this example):
- About 20 producer services. Volume is bursty: marketing campaigns send millions at once.
- Transactional messages, such as password resets, must arrive within seconds. Marketing messages can take minutes.
- Sending a duplicate is annoying but acceptable. Losing a password reset is not.
- Push and email only, for the first version.
What this tells us before any diagram:
- Two classes of traffic have different latency needs. That suggests separate priority paths.
- Bursts suggest buffering work instead of sending synchronously.
- "Duplicates acceptable, loss not" suggests at-least-once delivery.
- SMS is out of scope, which removes a vendor integration.
Notice that these conclusions came from questions, not from boxes. When the diagram arrives, each component has a reason.
You can record this in a small structure to keep it visible. This runnable snippet shows a framing note as data:
framing = {
"one_sentence": (
"Producer services request notifications; the system delivers "
"them to users by push or email."
),
"actors": ["producer service", "end user", "operator"],
"functional": [
"accept a notification request",
"deliver by push or email",
"report delivery status",
],
"non_functional": {
"transactional_latency_seconds": 5,
"delivery_guarantee": "at-least-once",
"bursty_load": True,
},
"out_of_scope": ["SMS", "user preference UI"],
}
for key, value in framing.items():
print(f"{key}: {value}")Writing the framing in a structured form, even informally on a whiteboard, makes gaps obvious. An empty list is a visible question.
Edge cases and gotchas
The prompt is a known product. "Design Twitter" invites you to recall the real architecture. Resist that. The real system reflects years of requirements you do not have. Define your own scope, and design for it.
The interviewer or stakeholder says "you decide." This is a request to state assumptions, not permission to skip them. Pick reasonable values, say them out loud, and note that you will revisit them if they are wrong. The next chapters cover this in detail.
Requirements conflict. "Strongly consistent, always available, and globally fast" cannot all hold at the same time under network failures. Name the conflict and ask which one gives way. Surfacing it early is a skill, not a failure.
Too many questions. Asking twenty questions before saying anything stalls the discussion. Ask the few that most change the design, make assumptions for the rest, and proceed.
Questions with no effect. Before asking, check that either answer would change your design. If both answers lead to the same architecture, skip the question.
Hidden non-functional needs. Users rarely mention security, privacy, or compliance, and they still matter. A quick "Does this hold personal data?" can reshape storage and access design.
Over-framing a small problem. If the system serves a small internal team, a one-paragraph framing is enough. Match the effort to the stakes.
Recognizing a well-framed problem
You are ready to move on when you can say yes to each of these:
- I can state the purpose in one sentence without naming a technology.
- I know the actors and what each one does.
- I have a short list of functional requirements and a short list of qualities with rough numbers.
- I know what is out of scope.
- I have written down my assumptions so they can be challenged.
Summary of the routine
- Restate the problem in one technology-free sentence.
- List the actors and their goals.
- Ask a few clarifying questions that would change the design.
- Sort the answers into functional and non-functional requirements.
- Draw the boundary and write down assumptions.
Only after these steps do you start drawing boxes.
Exercise
A teammate says "Design a chat app" and immediately proposes WebSockets, a message queue, and a sharded database. List four clarifying questions you would ask first, and for each one, say which part of the design the answer could change.
Show answer
Sample answers. (1) "Is it one-to-one chat, group chat, or both, and how large can groups be?" This changes message fan-out and the data model. (2) "How many daily active users, and how many messages per user per day?" This changes capacity estimates, and whether sharding is needed at all. (3) "Must messages be delivered in order and never lost, even if the recipient is offline?" This changes durability, storage, and delivery guarantees. (4) "Do we need read receipts, media attachments, or message history search?" This changes scope, storage choices, and the API. Any questions whose answers would change the design in a similar way are acceptable. A question such as "Should it be fast?" is too vague to count.
Exercise
You are told to design a service that "must be strongly consistent, always available during network partitions, and respond in under 10 ms worldwide." What should you do during framing, and why?
Show answer
Name the conflict instead of accepting all three. Under a network partition a system cannot be both strongly consistent and fully available, and a worldwide 10 ms target is limited by the speed of light between regions. Ask which requirement matters most, for example whether stale reads are acceptable or whether some operations can be slower. Then record the answer as an explicit trade-off in the requirements, so later design decisions can point to it.