Sub topic 15
Trade-offs between competing requirements
This chapter assumes you can classify a requirement as functional or non-functional. It also assumes you can read an SLO such as "99.9% over 30 days" and are comfortable with basic replication and caching ideas. Here you will learn why quality targets pull against each other, how to find the conflicts in a requirements list, and how to record the resolution.
Why requirements conflict
Each non-functional requirement is reasonable alone. Trouble starts when one design has to satisfy all of them. Most conflicts come from a few sources:
- Extra work per request (checks, coordination, encryption) costs time.
- Extra copies of data improve availability and durability, but they make agreement between copies harder.
- Extra safeguards cost money and add moving parts to operate.
A trade-off is not a defect in the requirements. It is a decision you have not made yet. If two requirements cannot both be met in full, someone has to choose, and the choice belongs in the requirements document, not in a developer's head.
Common tensions
| Requirement A | Requirement B | Why they conflict |
|---|---|---|
| Low latency | Strong consistency | A strongly consistent read may need to contact a leader or a quorum, which adds network round trips. |
| High availability | Strong consistency | During a network partition a replica must either refuse requests (consistent, less available) or answer from possibly stale data (available, less consistent). |
| Durability | Write latency | Waiting for data to reach disk or a second replica before acknowledging makes writes slower. |
| Security | Latency and usability | Token validation, encryption and audit logging add work to every request. |
| Low cost | Availability and durability | Each extra replica or region adds a bill. |
| Maintainability | Performance | Hand-tuned, specialized code is fast but harder to change than a simple design. |
The availability and consistency conflict only applies during a partition. When the network is healthy, you can usually have both. Write the requirement to say what happens during a failure, since that is where the choice is made.
Surfacing a conflict from the requirements document
Take the URL shortener requirements from earlier chapters. NFR-1 asks for 99% of redirects under 100 ms. NFR-2 asks for 99.9% availability. NFR-3 says a created short URL is never lost once creation is acknowledged. FR-3 lets a user delete a short URL.
Check each pair:
- NFR-3 pushes toward synchronous replication before acknowledging a write. That makes creation slower, but NFR-1 only covers redirects, so the two do not conflict. The scoping of NFR-1 to redirects is what keeps it clean.
- NFR-1 pushes toward caching redirects close to the user. FR-3 says a deleted URL stops working. A cache can keep serving a deleted URL until its entry expires. This is a real conflict between latency and freshness.
- NFR-2 pushes toward serving from any replica or cache even when the primary store is unreachable. That again allows stale answers.
The fix is to turn the vague worry into a number. For example: "After deletion, a short URL may still redirect for at most 60 seconds." This is a new requirement that states the accepted staleness. It tells the architect the cache time-to-live (TTL) can be up to 60 seconds. It also tells the tester exactly what to check.
Quantifying a trade-off
Availability trade-offs can often be computed. Components in a chain, where each must work, multiply their availabilities. Redundant copies, where any one is enough, multiply their failure probabilities. Both calculations assume failures are independent.
def serial(*parts):
"""Availability when every part must be up."""
result = 1.0
for availability in parts:
result *= availability
return result
def parallel(*parts):
"""Availability when any one part being up is enough."""
failure = 1.0
for availability in parts:
failure *= (1 - availability)
return 1 - failure
print(round(serial(0.999, 0.999), 6)) # 0.998001
print(round(parallel(0.999, 0.999), 6)) # 0.999999Two 99.9% components in a chain give about 99.8%, which misses a 99.9% target. Adding a second copy of each component raises the result sharply, at about twice the cost. The numbers let you say "this target needs redundancy, and it costs roughly double," which is a trade-off a stakeholder can accept or reject.
The independence assumption is the usual weak point. Two replicas in the same rack, using the same software version, can fail together. Real availability is lower than the formula suggests when failures are correlated.
Tunable consistency
Many replicated stores let you choose, per operation, how many replicas must respond. With N replicas, W acknowledging each write and R answering each read, reads see the latest acknowledged write whenever R + W > N.
| Setting (N = 3) | Write cost | Read cost | Behavior |
|---|---|---|---|
| W = 3, R = 1 | Slowest, fails if any replica is down | Fast | Consistent reads, poor write availability |
| W = 2, R = 2 | Moderate | Moderate | Consistent reads, tolerates one failure |
| W = 1, R = 1 | Fast | Fast | May read stale data |
Each row is a different answer to the same trade-off. The requirement tells you which row to pick.
Prioritizing and recording decisions
When two requirements cannot both be met in full, apply these steps:
- Ask which requirement has a hard consequence if violated, such as legal exposure, lost money or lost data. That one wins.
- Check whether the conflict applies to the whole system or only to one operation. Often reads and writes, or two different endpoints, can use different settings.
- Replace "fast" or "consistent" with a number that states the accepted compromise, as with the 60-second deletion window.
- Record the decision, the rejected alternative and the reason.
decision: DR-4
conflict: NFR-1 (redirect latency) vs FR-3 (deletion must take effect)
chosen: Cache redirects at the edge with a 60 second TTL.
accepted_cost: A deleted URL may still redirect for up to 60 seconds.
rejected: Check the primary store on every redirect; cannot meet NFR-1.
revisit_when: Legal requires immediate takedown of reported URLs.The revisit_when line matters. A trade-off reflects today's priorities, and the record should say what would change it.
Edge cases and traps
- Averaged requirements hide conflicts. A 100 ms average latency can coexist with a slow tail. Compare trade-offs using the percentile in the target, not the mean.
- Priority inflation. If every requirement is marked "critical," there is no basis for choosing. Force a ranking, even a rough one.
- Unstated costs. A requirement with no budget attached invites designs that satisfy it at any price. State the cost limit as a constraint.
- Resolving at the wrong level. Applying strong consistency to the whole system because one operation needs it makes every other operation slower. Relax it wherever the requirements allow.
Exercise
A service has a login component at 99.95% availability and a database at 99.9% availability. Both must be up for a request to succeed. A stakeholder wants 99.9% overall. Can the design meet it as is, and what is one option if not?
Show answer
Serial availability is 0.9995 × 0.999 = 0.9985005, about 99.85%, which is below 99.9%. The design misses the target. One option is to add a redundant database replica with automatic failover, so database availability rises well above 99.9% (assuming independent failures) and the product reaches about 99.95%. Another is to lower the target to 99.8%, which saves the replica cost but gives up availability the stakeholder asked for.
Exercise
A requirement says "Search results must be instant and always show the newest data." What conflict does this hide, and how would you rewrite it?
Show answer
It hides a conflict between low latency and freshness. Serving from a cache or index is fast but can be stale, and reading the source of truth on every query is fresh but slower. Rewrite it with numbers, for example: "99% of searches complete in under 200 ms, and a new item appears in results within 5 seconds of creation."