Skip to content

Drawing and checking

In the architecture stage of an interview, the picture matters less than what you do with it. A candidate who draws twelve boxes at once has nothing to say about why each is there. A candidate who draws three, runs the numbers through them, and adds the next box because a figure demands it, is showing the reasoning that the interviewer is looking for. The Arena gives this stage 10 of the 45 minutes, the largest share, and the Architecture Builder is the tool you use for it.

The method has four moves, and you repeat them.

  1. Draw the simplest design that does the job: a client, a service, a store.
  2. Run it at the load from your estimate.
  3. Read the bottleneck, which is the component asked for more work than it can do, and read what the checks say about the shape of the design.
  4. Change one thing, then run again.

Changing one thing is the rule that makes the method work. If you add a cache, a replica and a queue together, a better result teaches you nothing about which of them helped, and an interviewer cannot follow your argument either.

Mental model. A drawing is a claim, and a run is a test of it. The drawing says “this handles the traffic”. The run says how much traffic it handles, and which box gives up first.

The first Builder holds the design that most candidates draw first: a client, an API with four instances, and one database. It is set to 500,000 requests per second, 90% of them reads. Press Run at 500,000 RPS.

Architecture Builder

Draw a system as components and connections, set the load and run it. The engine shows where the design breaks, and the checks explain what to fix.

Workload

req/s
%

A workload with 80% reads or more counts as read-heavy: the cache and replica checks apply to it.

Components

  • ClientEntry point: every request starts here.
    Advanced settings: Client

    Empty means the default for this kind: 100,000.

    Empty means the default for this kind: 0.

    Empty means the default for this kind: no cap.

  • API
    Advanced settings: API

    Empty means the default for this kind: 16.

    Empty means the default for this kind: 2.

    Empty means the default for this kind: no cap.

  • Database
    Advanced settings: Database

    Empty means the default for this kind: 4.

    Empty means the default for this kind: 5.

    Empty means the default for this kind: no cap.

Add a component

Connections

  • Client → API
    Network time: Client → API

    Empty means 0.3 ms.

  • API → Database
    Network time: API → Database

    Empty means 0.3 ms.

Add a connection

A run is instant: the engine solves the design in steady state.

Run the design to see where it breaks.

Findings

Errors (1)
Warnings (3)
  • WarningAPI has several instances and no load balancer

    Components: API, Client

    Why this matters The client reaches API directly, so nothing spreads requests across its instances or takes a failed one out (load balancing); put a load balancer in front of it.

  • WarningReads go straight to Database, with no cache in front

    Components: Database

    Why this matters Most of the traffic is reads, so a cache in front of Database (caching) answers repeated reads from memory and leaves the store only the misses; set the hit ratio you expect and run again.

  • WarningDatabase has no replica to share the reads

    Components: Database

    Why this matters A read-heavy design with one copy of Database (replication) cannot spread its reads or survive losing it, so add replicas and send reads to them, accepting that a replica can lag.

Model notes

Assumptions

  • A run is a steady state at a constant rate. The engine solves queueing formulas; it does not replay individual requests.
  • The instances of a component share its load evenly.
  • A cache or a CDN answers with the hit ratio you set. The model does not predict that ratio.
  • Component sizes (instances, concurrent requests, time per request) are illustrative defaults, not measurements of any product.

Simplifications

  • Each connection takes 0.3 ms of network time unless you change it.
  • Failures, timeouts and queue limits are not simulated here. The warnings about them come from static rules over the design.
  • The share of the target load a design carries is found by raising and lowering the load until the engine first reports an overload.

Every number here is model output or an illustrative default, not a measurement.

Each component has a size, and the sizes are the Builder’s defaults. An API instance works on 16 requests at once and takes 2 ms for each, so the four instances can do 4 × 16 ÷ 0.002 = 32,000 requests per second. The database has one instance that works on 4 requests at once and takes 5 ms for each, so it can do 4 ÷ 0.005 = 800 requests per second. These sizes are illustrative: they are chosen to make limits visible and are not measurements of any product.

The result has three parts, and they answer different questions.

  • The headline names the component that limits the design: “Database is the bottleneck: it is asked for 32,000 req/s and can serve 800 req/s.” The database is asked for 32,000 and not 500,000 because the API in front of it can pass on no more than the 32,000 it can serve itself. The API is overloaded too: it is asked for 500,000 and can do 32,000, which is 15.6 times its capacity.
  • The share of the target load says how much of the 500,000 the whole design carries before the first overload: about 0.2%. That is 800 of 500,000. Put differently, the load is 625 times what this one database can serve. Even at 10,000 requests per second the same design carries about 8%.
  • The findings list what is wrong with the shape of the design, whatever the load: three errors and three warnings for this design, which the next section reads.

The Builder computes this with the same analytic engine as the labs in the case studies. A run is instant and always gives the same answer, because it solves a steady state and does not replay requests.

The six findings come from two sources. Two of them come from the run: the API and the database are overloaded, and the finding for the database repeats the share: “Database saturated at about 0.2% of target load (illustrative model)”. The other four are static checks, which read only the drawing and need no run.

Finding Kind What it says
Overloaded: API and database Error, from the run More work arrives than the component can serve at this load.
Single point of failure: database Error, from the drawing One instance on the request path, so losing it stops every request.
No load balancer in front of the API Warning, from the drawing The client reaches four API instances directly, and nothing spreads the requests or removes a failed instance.
Reads go straight to the database Warning, from the drawing 90% of the requests are reads and no cache sits in front of the store.
The database has no replica Warning, from the drawing A read-heavy design with one copy cannot spread its reads or survive losing it.

The two kinds of finding complement each other. The run tells you how much, and only for the load you chose. The checks tell you what is wrong in the structure, and they hold at any load. A design can pass every check and still fail the run, because the components are too small. It can also pass the run at a modest load and fail the checks, because it has a single instance of something that cannot be lost.

Fixing the plain design at 500,000 requests per second would take dozens of instances, and a candidate would never draw that on a whiteboard. Interviews use a size where each fix is visible. The second Builder is set to 5,000 requests per second, 95% reads, with a load balancer, four API instances and a database with two instances, the replica the checks asked for. Press Run at 5,000 RPS.

Architecture Builder

Draw a system as components and connections, set the load and run it. The engine shows where the design breaks, and the checks explain what to fix.

Workload

req/s
%

A workload with 80% reads or more counts as read-heavy: the cache and replica checks apply to it.

Components

  • ClientEntry point: every request starts here.
    Advanced settings: Client

    Empty means the default for this kind: 100,000.

    Empty means the default for this kind: 0.

    Empty means the default for this kind: no cap.

  • Load balancer
    Advanced settings: Load balancer

    Empty means the default for this kind: 256.

    Empty means the default for this kind: 0.05.

    Empty means the default for this kind: no cap.

  • API
    Advanced settings: API

    Empty means the default for this kind: 16.

    Empty means the default for this kind: 2.

    Empty means the default for this kind: no cap.

  • Database
    Advanced settings: Database

    Empty means the default for this kind: 4.

    Empty means the default for this kind: 5.

    Empty means the default for this kind: no cap.

Add a component

Connections

  • Client → Load balancer
    Network time: Client → Load balancer

    Empty means 0.3 ms.

  • Load balancer → API
    Network time: Load balancer → API

    Empty means 0.3 ms.

  • API → Database
    Network time: API → Database

    Empty means 0.3 ms.

Add a connection

A run is instant: the engine solves the design in steady state.

Run the design to see where it breaks.

Findings

Warnings (1)
  • WarningReads go straight to Database, with no cache in front

    Components: Database

    Why this matters Most of the traffic is reads, so a cache in front of Database (caching) answers repeated reads from memory and leaves the store only the misses; set the hit ratio you expect and run again.

Model notes

Assumptions

  • A run is a steady state at a constant rate. The engine solves queueing formulas; it does not replay individual requests.
  • The instances of a component share its load evenly.
  • A cache or a CDN answers with the hit ratio you set. The model does not predict that ratio.
  • Component sizes (instances, concurrent requests, time per request) are illustrative defaults, not measurements of any product.

Simplifications

  • Each connection takes 0.3 ms of network time unless you change it.
  • Failures, timeouts and queue limits are not simulated here. The warnings about them come from static rules over the design.
  • The share of the target load a design carries is found by raising and lowering the load until the engine first reports an overload.

Every number here is model output or an illustrative default, not a measurement.

Two instances of the database make 1,600 requests per second. It is asked for all 5,000, which is 313% of its capacity, so the database is the bottleneck and the design carries about 32% of the load. The API is at 16% of its capacity, so it is not the problem. There are two findings: the database is overloaded, and the reads go straight to it with no cache in front.

The change is a cache between the API and the database. In list mode, press Add component, choose the cache, then use Connect to join the API to the cache and the cache to the database, and remove the direct connection from the API to the database. A new cache has a hit ratio of 0.95 until you change it, and that ratio is a number you set, not one the model derives. Run again.

  • The database is now asked for 5% of 5,000, which is 250 requests per second, and is 16% busy. No component is overloaded.
  • The design carries up to 6.4 times the target load, which is 32,000 requests per second. Who gives up at that point is the API, not the database: the bottleneck has moved.
  • A new warning appears: the cache has one instance, so it is a single point of failure. Fixing a problem usually exposes the next one, and naming it before the interviewer does is part of the answer.

Raise the load to 100,000 requests per second and run again to see the move. The engine now names the API as the bottleneck: asked for 100,000, able to serve 32,000, and the design carries about 32% of that load. The cache is at 80% of its capacity. The next change would be more API instances, and it would put the cache next. That is the loop: draw, run, read, change one thing.

A cache like this one holds copies of data that was read before, so it only helps when the same data is read again. The Cache-Aside pattern, which loads data into the cache on demand, is the usual way to do it, and the cache-aside lesson explains it, including what the hit ratio depends on, which the Builder leaves to you.

The Builder has eight static rules. Each rule is a plain test over the drawing, written to match something an interviewer asks about. The thresholds below are the course’s choices, not industry standards.

A component on the request path with fewer than 2 instances is flagged. It is an error for a database, a queue or a broker, which hold state, and a warning for anything else. The client is not counted, because it stands for the users. The answer is at least two instances, and for a database a replica that can take over: see failover. The first Builder shows this for the database. If you set its instances to 2, the finding disappears, and so does the “no replica” warning. The design still carries only about 0.3% of the load, because the capacity is 1,600 and the load is 500,000. Removing a finding is not the same as fixing the design, and it is worth saying so out loud.

When 80% or more of the requests are reads, two checks apply. If a database, a search index or an object store is called by an API, and no cache sits anywhere upstream of it, the first check fires: reads should be answered from memory when the same data is read again and again. If a database has a single instance, the second fires: the reads cannot be spread, and the store cannot be lost. Both appeared on the first design, and the first on the second design too. Below 80% reads, neither check applies: with fewer reads there is less for a cache or a replica to take over. The single-leader replication lesson explains why replicas add read capacity and not write capacity.

A request that waits through more than 5 calls in a row is flagged. The design in the Builder’s preset called “A long synchronous chain” has six: from the client to the load balancer, a gateway, then three services called Orders, Inventory and Pricing, and the database. Run at 1,000 requests per second, it is healthy, with a mean latency of about 15.1 ms, and still gets a warning, because latency and failure both accumulate along a chain. Each hop adds its own time and 0.3 ms of network time. And if each of the six components were up 99.9% of the time and they failed independently, the chain would be up about 99.4%, since the chance of being up is multiplied at every hop (the availability lesson has a calculator for components in series). The fixes are to shorten the chain, merge steps, or make a call asynchronous so the request no longer waits for it.

A synchronous call from an API to a worker, or to any component that takes 100 ms or more per request, is flagged: the user waits for slow work, and the API is tied to its speed. So is a write-heavy design, one with 50% reads or fewer, where an API writes to a database directly and no queue or broker exists anywhere. The Azure Architecture Center describes the remedy as a queue that acts as a buffer between a task and the service it calls, smoothing intermittent heavy loads.

The preset “Writes through a queue” has 600 requests per second, 20% reads, and a queue between the API and the workers. The same writes sent straight from the API to the database get the warning, and the mean latency is about 8.0 ms, against about 4.0 ms with the queue, because the request no longer waits for the database. The workers are 56% busy and the database 38%, and the design carries up to 1,067 requests per second, which is what the workers can do. A queue does not remove the limit. It moves it to the component that works at its own pace, and it lets the request finish early. The queues lesson goes further.

A connection that retries into a database, a queue, a broker, a worker or an API, and is not marked idempotent, is an error. A retry can arrive twice, and unless the callee treats a repeat as the same request, the work is done twice. The same preset retries the workers’ calls to the database twice, and marks the call idempotent. Clear that setting and the finding appears. Amazon’s Builders’ Library prefers a unique caller-provided request identifier in the API contract, so that requests from the same caller with the same identifier can be treated as duplicates. Its article on timeouts and retries adds that retries multiply across layers: in a stack five calls deep with three retries at each layer, a failing database can see 243 times the load, so a retry is never free. The idempotency keys lesson and the timeouts and retries lesson give the details.

A design with several API instances reached directly from the client gets a warning to add a load balancer, because nothing spreads the requests or takes a failed instance out. A component that no request can reach is reported as a note: it costs money and adds no capacity, and in an interview you must be able to justify each box.

Which one did you see first on your own drawings? Check yourself.

Interview Arena: check the design

This quiz needs JavaScript to check your answers.

Question 1 of 6

In the Architecture Builder, a client calls an API with 4 instances, and the API calls one database, at 500,000 requests per second with 90% reads. The database is the bottleneck: it can serve 800 requests per second, and the design carries about 0.2% of the target load (illustrative model).

Which change moves the limit the Builder reports?

Choose one answer.

Question 2 of 6

The same design has 4 API instances and 1 database instance.

Which component is the single point of failure, and why is the API not one even though it does the most work?

Choose one answer.

Question 3 of 6

In the Builder, 5,000 requests per second reach a cache with a hit ratio of 0.95, and each miss goes on to the database.

How many requests per second does the database receive?

Enter a number and choose its unit.

requests per second
Question 4 of 6

A design runs 6 synchronous calls in a row from the client: load balancer, gateway, three services and the database. At 1,000 requests per second no component is overloaded and the design carries about 1.6 times the load. The Builder still shows a warning.

Why?

Choose one answer.

Question 5 of 6

A write path has an API that puts each write in a queue, and workers that apply it to the database. The workers retry a failed write up to 2 times.

What must be true so that a retry cannot apply the same write twice?

Choose one answer.

Question 6 of 6

In the write-heavy design (20% reads), the API does not write to the database itself. It hands each write to a queue, and workers apply it at their own pace.

What does the queue buy, and what does it cost?

Choose one answer.

The Builder has two editors over the same design. List mode is the default: a table of components and a table of connections, with forms to add, change and remove each. Everything in it is reached with the keyboard, in the order you read it, and it is the right choice with a screen reader. Canvas mode is a drawing surface where you drag components and join them with lines. It is offered only when the window is at least 768 px wide, it is loaded the first time you switch it on, and your choice is remembered in the browser. Switch with Canvas mode, and you can switch back at any time, since the design is the same object: a connection made on the canvas appears in the table, and the reverse. The canvas has a note that points to list mode for a keyboard-only or screen-reader workflow. Your design is saved in the browser as you edit, so you can leave and come back.

In practice, list mode is faster once you know the kinds of component, and canvas mode is easier for seeing the shape. Use whichever you will use in the interview, which is a whiteboard: neither replaces the habit of saying what each box is for.

The first design looks right. A client, an API with four instances and a database is what many candidates draw, and nothing in the picture says that it carries about 0.2% of its target load. A drawing has no numbers: the same three boxes can be a design for 800 requests per second or for 500,000. Only a run, or your own arithmetic on the estimate, tells the two apart, and the arithmetic is the same as the run’s: the load divided by what the component can serve.

The reverse also happens. A candidate who adds every box that comes to mind builds a design that carries the load and fails the checks, with a cache, a queue, a broker and a long chain that nothing demanded. Each box is something to run, to pay for and to explain. The method guards against both: a box earns its place by a number or a finding, and you can say which.

The architecture stage of every Arena scenario opens the Builder with an empty design, and the workload of the scenario already set. You draw the design, press the run button, and write your answer in words. The Builder’s findings on your design are shown beside the rubric as evidence. They are never counted in your score, because a design can pass every check and still be a poor answer to the question, and a good answer can break a rule on purpose and explain why. The one-line summary of your design and its findings is added to the end of your answer. Go to the Arena when you are ready.

Interview question

Writing and reviewing an answer needs JavaScript.

The interviewer asks

Design a pastebin: a user pastes a block of text, gets a link, and shares it. Anyone with the link can read the text, and every paste expires. Walk through your design.

Assume 10 million new pastes a day of about 10 KB each (up to 1 MB), each read about 9 times, and an average life of 30 days.

Write your answer first. The strong answer unlocks once you have written a real attempt.

0 of 80 characters written to unlock the strong answer

  • The method has four moves: draw the simplest design, run it at the load from your estimate, read the bottleneck and the checks, change one thing and run again.
  • The plain design (client, API with 4 instances, one database) at 500,000 requests per second has the database as the bottleneck: asked for 32,000 and able to serve 800. The design carries about 0.2% of the load, and gets three errors and three warnings.
  • A second database instance removes the single-point and replica findings, and the design still carries only about 0.3%. Removing a finding is not fixing the design.
  • At 5,000 requests per second with 95% reads, two database instances (1,600 per second) carry about 32%. A cache with a 0.95 hit ratio leaves the database 250 requests per second and lets the design carry up to 6.4 times the load, and the next limit is the API at 32,000.
  • The checks to know: a single point of failure, reads with no cache or replica (80% reads or more), a synchronous chain of more than 5 calls, a slow or write-heavy call that wants a queue, and a retry that is not idempotent.
  • List mode is the default and works with a keyboard and a screen reader. Canvas mode, from 768 px up, edits the same design.

Next: Failure scenarios, where the interviewer asks what happens when something breaks.

Your progress

Built by GhaziAlibi.

© ShardCraft. All rights reserved.