On this page
What you need first
This lesson uses ideas from these earlier lessons. Read them first if any idea is new to you.
01Why interviewers ask this
In the design step of the round (lesson 2), you draw. The interviewer often points at one box and asks: "What happens here?"
A weak drawing has boxes named "Frontend" and "Backend" and no numbers. A strong drawing is small. Each box has one job, and numbers show the load. In our guide, SDE-1 needs a correct drawing. SDE-2 and SDE-3 also need numbers that match the requirements.
02The idea in plain words
Think about a road map. It shows which roads join which places, and how many vehicles each road carries. You read it to find the busiest road.
An architecture diagram is a drawing of the parts of a system and the calls between them. It needs two shapes.
- A box is one part: the client, the servers, or the database (lesson 1). One box has one job. If you cannot say the job in one short sentence, split it.
- An arrow is one call. It points from the part that asks to the part that answers. The answer comes back on the same arrow, so you do not draw it again. Some people point arrows the way data moves. Either is fine if you say your rule.
A label is the short text on a box or an arrow. It carries the numbers from lesson 2, with units.
- On an arrow: what is sent and the load, which is how many requests arrive each second. For example: "getResult, 667 requests per second".
- On a box: its name and its capacity, the most it can do each second. For example: "Server x 3, each 500 requests per second".
To read a diagram:
- Follow one request along the arrows. This is the data flow from lesson 2. Number the arrows in order.
- Divide the load going into a box by its capacity. This shows how full it is. Above 100% means it is too small.
- Find the box that fills first. Use it for a deep dive.
- Ask about each box: "If it breaks, does the system stop?" If there is only one of it, it does.
To draw a diagram: start with the smallest design that meets the requirements. Add a box only when a number needs it. Use 5 to 8 boxes. Put the client on the left.
Stuck on something? The AI tutor has read this lesson. Ask it with a free account
03Pause and predict
Pause. Guess first.
A drawing shows one box, "Server, 500 requests per second". The arrow into it says "667 requests per second". What do you learn from the drawing alone?
Write your guess before you read on. The worked example answers it.
04Worked example
We draw the results website of lesson 2. Assumptions (made up to teach with): 667 requests per second at the busiest time. One server answers 500 requests per second. The database answers 2,000 lookups per second. Each request makes one lookup.
Boxes: Phone, Servers x 3 (each 500 requests per second), Database (2,000 lookups per second).
| Arrow | From and to | Label |
|---|---|---|
| 1 | Phone to Servers | getResult, 667 requests per second |
| 2 | Servers to Database | 667 lookups per second |
Reading it.
- One server: 667 / 500 = 1.33, so the load is 133% of capacity. This answers the predict box: it is too small by 667 - 500 = 167 requests per second.
- Three servers, with the requests shared equally: 667 / 3 = 222 each, and 222 / 500 = 44% full.
- Database: 667 / 2,000 = 33% full.
- Room to grow: the servers hold 1,500 / 667 = 2.25 times today. The database holds 2,000 / 667 = 3 times today. The servers fill first.
- If one server breaks, 667 / 2 = 333 each, 67% full. The site works. If the database breaks, the site stops.
05Trade-offs
- Labels solve a drawing that nobody can check. They cost drawing time, and you must defend every number. I would label only the busiest arrow when time is short.
- A small drawing solves confusion. It costs detail. I would add a box when a number needs it.
06Common misconceptions
"More boxes show that I know more." Extra boxes hide the idea. The interviewer scores choices that fit.
"An arrow always shows where the data moves." Here it shows who asks. Arrow 2 points to the database, but the marks come back on the same arrow. Say which rule you use.
"I can keep the numbers in my head." The interviewer cannot see them. Without numbers, nobody can tell if three servers are enough.
07How to say it in the interview
Say it like this
I will draw the smallest design first: the phone, three servers and one database, with the load on each arrow. The servers are 44% full, and the database is the one box whose failure stops the site.
08Check your understanding
- What does a box mean? What does an arrow mean, and which way does it point?
- An arrow into the servers says "900 requests per second". One server answers 500. Each request makes 2 lookups. The database answers 2,000 lookups. (a) With 2 servers, how full is each? (b) How many servers do you need, so that the site works when one breaks? (c) How full is the database?
- A drawing has 12 boxes named "Service A" to "Service L", no numbers, and an arrow from the database to the phone. Name three problems.
09Answers
Show the answers
- A box is one part with one job. An arrow is a call, and it points from the part that asks to the part that answers.
- (a) 900 / 2 = 450, and 450 / 500 = 90% full. (b) With 2 servers, one broken leaves 500, less than 900. With 3, two are left: 2 x 500 = 1,000, more than 900. So 3. (c) 900 x 2 = 1,800 lookups per second, and 1,800 / 2,000 = 90% full.
- The names say no job. There are no numbers. The database never asks the phone, so that arrow is wrong. Twelve boxes are too many for a first drawing.
Try it now, no sign-up
- Play Level 1: one server and 100 users. Free, no sign-up.
- Read today’s Drill: one real situation, answered in about 7 minutes.
More practice, in the app (free account)
Related lessons and practice
Ask the AI tutor about this lesson
The tutor has read this lesson. Ask in your own words, any time. Free account, 20 questions a day.
Reading never needs an account. The account is for the tutor, the quiz, your notes and your progress.