Advanced System Design Fundamentals
Vote

0% completed

​

From Correct to Right

Part 1: Two Correct Designs

Part 2: Correct Versus Right

Part 3: How Many Systems Five Engineers Can Run

Part 4: Time Is the Real Budget

Part 5: Start From the Smallest Design

Part 6: Buying Without Getting Stuck

Part 7: Using This in an Interview

Common Mistakes

Key Takeaways

From Correct to Right in System Design: Fitting a Design to Team Size, Time, and What Five Engineers Can Run (Video)

A design is correct when it meets every requirement in the question. A design is right when it also fits the people and the moment. It suits the team that must build and run it, the time that team has, and the load the system will really see.

The two can differ. A design that could serve a hundred times the expected load is correct. For a startup with five engineers, it can also be the wrong choice. The parts below show how to tell a correct design from a right one, and how to explain the difference.

Part 1: Two Correct Designs

The running example is one interview question, and every Part comes back to it.

"Design a service that reminds patients about their appointments, for a clinic-booking app. The company is a startup with five engineers, and the feature must launch in three months."

The app books about 20,000 appointments a day. Each patient gets one text message, sent the day before the visit, and it may arrive a minute or two late. These numbers are examples.

Design A adds a scheduling service, an event stream, workers, a new reminder database, and a cache. An event stream is a shared log of messages that many services can read in order. The workers send each text through a hosted service, which another company runs for a fee. Design A could handle a hundred times the load.

Design B adds one table to the app's existing database. A scheduled job runs every minute, finds the reminders that are due, and hands each one to the same hosted service.

The diagram below shows both designs side by side.

Two designs that both meet the stated requirements, one with eight systems to run and one with three
Two designs that both meet the stated requirements, one with eight systems to run and one with three

Notice the line under each design. Design A has eight systems to run, and Design B has three. Neither design is wrong, but only one fits this company. The rest of the lesson explains why.

Part 2: Correct Versus Right

Both designs pass the first test, so the lesson needs names for the two tests. A design is correct when it meets the stated requirements. Correctness is a property of the design alone.

A design is right when it also fits the people and limits around it. Rightness is a relation between the design and its setting, and five constraints decide it:

  • Team size: how many engineers will build and run it.
  • Timeline: how soon it must work.
  • Operational capacity: how much the team can watch, repair, and upgrade once it is live.
  • Budget: what the company can spend on servers and services.
  • The existing system: what is already running, and what the team already knows.

Design A strains most of these. Five new systems in three months leave little time for other work, and the team must run all of them after launch.

Two common tie-breakers are weaker. Fewer technologies usually helps, but it is a rule of thumb, and a small design can still be wrong for the team. Better load-test results do not settle it either, because both designs already meet the stated load.

Part 3: How Many Systems Five Engineers Can Run

Of the five constraints, operational capacity is usually the hardest for a small team. Its limit is running systems, not building them.

Running a system includes being on call. Being on call means answering alerts day and night, often for a week at a time. With five engineers on a weekly rotation, each person is on call one week in five. That person must fix whatever breaks, whoever built it.

That sets a practical ceiling. As a rough guide, a team of five can run about three or four distinct systems, counting every datastore and pipeline. Two terms matter in that count:

  • A datastore is any system that keeps data, such as a database or a cache.
  • A pipeline is a chain of steps that moves data between systems.

Past that point, some system is often one the person on call barely knows. An app with a database, a queue, and a cache is a common and workable set.

A managed service is one whose servers a cloud provider patches and upgrades. It helps, but it does not remove the limit, because the engineer on call must still understand it.

Now count the systems in Part 1. Design B runs three: the app, its database, and the hosted text service. Design A runs eight. For a team of five, that difference decides the question.

Part 4: Time Is the Real Budget

The count of systems is one limit. The other is time, because for a small team, engineer time usually costs more than servers. A useful unit is the engineer-quarter, which is one engineer working for one quarter, or three months. The diagram below shows a year of work for a five-person team.

A five-person team has twenty engineer-quarters in a year, and one engineer for one quarter uses one of them
A five-person team has twenty engineer-quarters in a year, and one engineer for one quarter uses one of them

Notice the single cell marked "Migration" among the product work. Five engineers times four quarters gives 20 engineer-quarters a year. One engineer spending a quarter on a database move uses one of 20, or about 5 percent of the year.

At a company with 200 engineers, the same move is routine. At five engineers, it is a major decision that delays other work. Only the total it is divided by has changed.

Every extra system in Design A brings future upgrades, outages, and perhaps a migration. Each of these is paid in engineer-quarters.

Part 5: Start From the Smallest Design

Parts 3 and 4 showed why Design A is too large. The most reliable way to reach the right size is to start small and add. Ask one question first. What is the smallest design that meets the stated requirements, adding only what a requirement forces?

Starting from the other end leads to Design A. That approach pays now for a scale the company may never reach. It may also copy a reference design built for someone else's constraints. Listing the parts such systems usually have gives a full diagram in which no part has a reason.

Once a design is on the board, test each part with one question. What would have to be true for this part to be necessary, and has that been established? The diagram below applies it to four parts of Design A.

Four parts of the larger design, each tested against the condition that would make it necessary
Four parts of the larger design, each tested against the condition that would make it necessary

Step 1: The event stream. It is needed when many services must react to each booking. Only one service reacts here, so remove it.

Step 2: The separate reminder database. It is needed when the main database cannot take the extra writes. 20,000 new rows a day is small, so remove it.

Step 3: The cache. It is needed when the same data is read many times. Each reminder is read once, so remove it.

Step 4: The hosted text service. It is needed when the team cannot build and run its own link to the phone networks. That is true, so keep it.

Notice that only one of the four parts survives the test. The scheduling service and the workers fail the same test, because one scheduled job can send 20,000 texts a day. What remains is Design B, and every part that survives has a reason attached.

Right does not always mean small. At 50 million appointments a day, one job may no longer keep up. Then a queue with workers has a reason. Judgment means adding a part when a requirement forces it, and not before.

Part 6: Buying Without Getting Stuck

Step 4 kept one part that the team buys, the hosted text service. Buying a hosted service saves engineer-quarters now. The cost of leaving it later depends on how the service was connected, not on which service it was. Two teams show the difference.

Team 1 calls the provider from one small module. The rest of the code calls sendReminder(phone, text) and never sees the provider. This is a narrow interface, which is a small, fixed set of calls that hides what is behind it. Replacing the provider means rewriting one module.

Team 2 stores the provider's message IDs, status codes, and template names in tables across the app. The provider's ideas have spread through the code, so replacing the provider means a rewrite.

An export tool from the provider, or a short contract, helps only a little, because neither changes how far the provider's ideas spread. Design B connects like Team 1. Its scheduled job is the only code that talks to the text service.

Part 7: Using This in an Interview

This lesson's question stated the team size and the timeline, but many questions do not. When they are missing, ask once, or state an assumption with its consequence.

"I'm assuming about five engineers and a launch in a few months. So I'll keep this to the app, its database, and a hosted text service. If a platform team already ran an event stream, I would use it, because someone else would run it."

The last sentence names the condition that would change the design. If asked why there is no event stream, say what would have to be true for it, as in Step 1 of Part 5. If asked about a hundred times the load, name the first part that would break.

Common Mistakes

Mistake 1: Designing for the company you hope to become. Build for the stated load, and say what would make you add more.

Mistake 2: Treating a correct design as finished. Check it against the team, the timeline, operations, the budget, and the existing system, because a correct design can still be wrong for the team.

Mistake 3: Counting only the cost of building. Every system must also be run by whoever is on call that week.

Key Takeaways

  • Correct and right are different tests. Correct means the design meets the requirements. Right means it also fits the team, the timeline, the team's capacity to run it, the budget, and what already exists.
  • A small team's limit is running systems, not building them. As a rough guide, five engineers can run about three or four, counting every datastore and pipeline.
  • Measure time in engineer-quarters. One engineer for one quarter is about 5 percent of a five-person team's year.
  • Start from the smallest design, and add only what a requirement forces. Test each part by asking what would have to be true for it to be needed.
  • In a system design interview, state the team and timeline you are assuming, and say what would change your design if they were different.

The next lesson, Narrating Your Thinking, shows how to make reasoning like this audible while you design.

Reading Progress

0%


Vote for new content

On This Page

Part 1: Two Correct Designs

Part 2: Correct Versus Right

Part 3: How Many Systems Five Engineers Can Run

Part 4: Time Is the Real Budget

Part 5: Start From the Smallest Design

Part 6: Buying Without Getting Stuck

Part 7: Using This in an Interview

Common Mistakes

Key Takeaways