Constraints and trade-offs: what you cannot negotiate
Three things that are easy to mix up
Section titled “Three things that are easy to mix up”When a team talks about “what the system has to be”, three different kinds of statement get mixed up:
- A requirement says what the system must do or how well. Checkout answers in under 500 ms for 99% of requests.
- A constraint is fixed from outside the design. It limits which designs are possible. The launch is in ten weeks.
- A design decision is a choice the team makes, from several that would have worked. Product data lives in PostgreSQL.
The difference matters because you treat them differently. A requirement is what you judge the design against. A constraint is what you design within. A decision is yours: you can revisit it when the facts change. Treating a decision as a constraint (“we have always used this database”) closes options for no reason, and treating a constraint as a decision (“we will just hire more people this month”) plans around something you cannot change.
Mental model. Requirements say where you must get to. Constraints are the walls of the room you must do it in. Decisions are the route you choose inside the room.
Six kinds of constraint
Section titled “Six kinds of constraint”| Kind | Example | What it limits |
|---|---|---|
| Time | Launch in ten weeks, before the holiday season | How much can be built, and how well it can be tested |
| Money | An infrastructure budget of 5,000 a month | Which designs are affordable to run |
| People | Four engineers, nobody has run a database cluster | Which designs the team can build and keep running |
| Rules | A contract says customer data stays in the European Union | Where data may live, whatever you would prefer |
| Existing systems | The company has committed to one cloud provider | Which technologies and services you can choose from |
| Physics | Signals cannot travel faster than light | How fast any answer can be, whatever you spend |
The first five are negotiated by people, and in the end someone can change them. The sixth cannot be negotiated at all.
Physics sets a floor
Section titled “Physics sets a floor”Light travels in an optical fibre at about two thirds of its speed in a vacuum, roughly 200,000 kilometres a second, which is 200 kilometres per millisecond. Stuart Cheshire’s classic note works through an example: the distance from Stanford, near San Francisco, to Boston is about 4,320 kilometres. Even in a fibre laid in a perfect straight line, a signal needs
- 4,320 ÷ 200 = 21.6 ms one way, and
- 43.2 ms for the round trip.
No hardware, software or budget gets below that. Cheshire measured an actual round trip of 85 ms on that route, about twice the floor. Real paths are longer than the straight line, and routers add delay.
This floor has a consequence for design that no cache or faster server can remove: if your users are far from your data, every round trip they wait for costs at least that much. A page that needs five round trips in a row to a server across such a distance takes at least 5 × 43.2 ms = 216 ms before any work is done. There are two ways around it: make fewer round trips, or move the data closer to the user with a CDN or a regional copy. The networking and multi-region modules come back to both.
Sort them out
Section titled “Sort them out”Eleven statements about the shop. Which are constraints, which requirements, and which decisions?
Challenge
Constraint, requirement or decision?
A constraint is fixed by something outside the design: time, money, people, rules, the systems already there. A requirement says what the system must do or how well. A design decision is a choice the team makes and could make differently. Sort these statements about the online shop.
Sorting needs JavaScript.
Categories
- Constraint
- Fixed from outside. The design has to live with it.
- Requirement
- What the system must do, or how well.
- Design decision
- A choice we make, and could make differently.
Check your answers at least once before looking at the answers.
Every design is a trade-off
Section titled “Every design is a trade-off”Nothing is free. When you choose something, you get what it offers and you pay for what it costs, and you rule out the alternatives. The choice that is best for one set of requirements and constraints is worse for another. That is why there is no “best architecture”, only the best one for these requirements inside these constraints.
Write a trade-off down in a way that makes the price visible. The course uses the same seven steps throughout:
| Step | Question | Example: serve product images through a CDN |
|---|---|---|
| Decision | What exactly are we choosing? | Serve product images from a content delivery network |
| Why | What problem does it solve? | Images are read far more than they change, and customers are far from our servers |
| Benefits | What do we get? | Faster pages, much less load on our servers |
| Costs | What do we pay? | A monthly bill, and a copy of every image outside our control |
| Failure modes | How does it fail? | A changed image is still served old until its copy expires or is purged |
| Scaling limitations | Where does it stop working? | Pages that differ for every customer cannot be shared this way |
| Alternative | What else could we have done? | Serve from our own servers, in a few regions |
A decision with an empty “costs” row has not been understood yet.
What happens if a constraint changes?
Section titled “What happens if a constraint changes?”The shop was planned for ten weeks with four engineers: forty engineer-weeks of work. Then the date moves up. The launch is now in six weeks.
Six weeks with the same four engineers is 24 engineer-weeks, which is 40% less. The work does not shrink to fit. Something has to give, and there are only three places for it to come from:
- Scope: leave out features, for example the seller export.
- Quality targets: accept a lower requirement, for example 99.5% availability at launch instead of 99.9%.
- The constraint itself: ask whether the date is really fixed, or whether more people or money can be added. (More people rarely help late in a project.)
All three are decisions. The skill is to see that a change in a constraint forces one of them, and to make it on purpose instead of finding out in week five.
- A requirement is what the system must do or how well. A constraint is fixed from outside the design. A decision is a choice that the team could make differently.
- The usual constraints are time, money, people, rules, existing systems, and physics.
- Light in fibre travels about 200 km per millisecond, so a round trip over 4,320 km cannot take less than 43.2 ms. Real ones take longer. Distance is a constraint that only moving the data can reduce.
- Every design is a trade-off. Write it down as decision, why, benefits, costs, failure modes, scaling limitations and alternative.
- When a constraint changes, scope, quality targets or the constraint itself has to give. Choose which on purpose.
Next: state, what a system remembers, and why it matters so much for scaling.
Your progress
Built by GhaziAlibi.
© ShardCraft. All rights reserved.