Skip to content

Advanced Concepts · Concept lesson

Architecture Evolution: Change Safely Without a Rewrite

Evolve systems through small reversible changes, explicit contracts, and evidence-driven boundaries instead of betting on a big rewrite.

Written for readers who already know the basics. If the words here are new to you, read The request lifecycle and Capacity estimation first.

Original educational architecture · Version 2026-11-12.1 · Examples use stated hypothetical assumptions, not a company's actual design.

What you will be able to explain

  • Use evolutionary architecture fitness functions to make constraints continuously testable.
  • Plan migrations with compatibility windows, dual-run evidence, and rollback boundaries.
  • Choose extraction or replacement based on coupling and operational capability.

Architecture is a set of hypotheses that must survive change

An architecture records decisions about boundaries, data ownership, failure modes, and change cost. Those decisions are hypotheses about future workload and team behavior; some will become wrong. A useful architecture makes the cost of changing a hypothesis manageable. This means stable contracts, narrow ownership boundaries, observable behavior, and reversible deployment steps. It does not mean building every possible abstraction before the use case exists. A monolith can have clear module boundaries and be easier to evolve than a network of tiny services. A service split is valuable when independent change, scaling, ownership, or fault isolation outweighs the new network and operations costs. Evolve from evidence such as repeated coordination pain, contention, or scaling limits rather than a diagram preference.

An architectural fitness function turns an important quality attribute into a recurring check. Examples include a maximum latency budget for a critical path, a test that prohibits one module importing another module's persistence layer, a dependency update report, a restore drill, or a cost-per-job threshold. Not every quality can be reduced to one automated number. A test can prove a module boundary but not that teams understand it. Use both machine checks and review practices. Fitness functions need owners and an action when they fail; a red dashboard ignored for six months is not an architecture control. Keep the checks proportional so they guide change rather than make ordinary changes impossible.

Use contracts and expand-contract migrations

For an API or database change, first expand the contract so old and new consumers can coexist. Add a nullable or defaulted field, a new endpoint version, or a new table while leaving current behavior intact. Deploy readers that understand both old and new forms, then deploy writers that produce the new form. Backfill existing records in bounded batches with checkpoints and version validation. Measure old-consumer traffic and data parity. Only after every active consumer has moved should the old field or endpoint be removed. This staged sequence avoids the common failure where a deployment rolls out new code before the database is compatible.

A migration should have observable checkpoints, explicit owner, timeout, pause condition, and rollback strategy. A schema change can be forward-compatible but not safely reversible after new data is written; in that case rollback may mean deploying a compatible old binary rather than restoring the old schema. Backfills should be idempotent and rate-limited to protect live traffic. Dual writes can diverge if one path fails; if temporary dual write is unavoidable, compare state and define source of truth. Prefer a single write path with a replication or change-capture mechanism where possible. Record a migration version on the data or job so retries know which transformation applies.

Replace a legacy report path one route at a time

Suppose a legacy report endpoint takes 4 seconds at p95 and frequently overloads the main database. A new read model can be built from change events, but it will be eventually consistent. First instrument the endpoint's user outcome, query shape, freshness need, and top expensive dimensions. Build a read model in shadow mode that receives the same changes while the legacy endpoint remains authoritative. Compare result counts and sampled fields over a representative week; establish tolerances for known ordering or rounding differences. Do not return shadow data to users merely because the service starts successfully.

Next route a small percentage of eligible requests to the new path behind a kill switch. Compare error rate, p95/p99, data freshness, database load, and cost per report. If 1% of 100,000 requests per day is 1,000 canary requests, that may be too small to reveal a rare correctness defect; choose the sample based on risk and statistical evidence, not an arbitrary percentage alone. Increase traffic in stages, keeping the old path operational and maintaining a rollback window. Once the new path meets objective thresholds and backfill parity is demonstrated, move all reads and later retire the legacy query. If the new path is stale beyond its freshness objective, route affected requests to a safe fallback only within bounded source capacity.

Expand-contract migration with measured cutover
1. Legacy path

Continues serving as the trusted behavior during migration.

2. Compatible contract

Adds new schema or interface without removing old consumers.

3. New implementation

Runs in shadow mode and produces parity evidence.

4. Traffic canary

Small reversible routing step behind a kill switch.

5. Fitness checks

Compare correctness, latency, SLO, freshness, and cost.

6. Retire old path

Only after consumer migration and rollback window.

  1. Legacy path → Compatible contract: preserve current behavior
  2. Compatible contract → New implementation: compatible rollout
  3. Legacy path → New implementation: shadow compare
  4. New implementation → Traffic canary: parity threshold met
  5. Traffic canary → Fitness checks: observe real traffic
  6. Fitness checks → Legacy path: rollback if regression
  7. Fitness checks → Retire old path: validated cutover

Choose seams from change ownership and failure isolation

A modular monolith can enforce boundaries through packages, interfaces, and ownership rules without a network hop. It is often the right choice when a small team shares one release process and transactions span related data. Extracting a service adds independent deployment and scaling, but requires remote authentication, retries, tracing, schema evolution, on-call ownership, and partial-failure handling. A separate service may be justified when one workload has distinct scaling needs, one team owns the domain end to end, or a failure must be isolated. It is not justified solely because the code is large or a framework makes extraction easy.

A big-bang rewrite replaces unknown behavior all at once and risks losing tacit rules, edge-case compatibility, and production learning. A strangler approach redirects a bounded capability and lets the system shrink in pieces, but it can leave two implementations and data stores active for a long time. A branch-by-abstraction introduces an interface around existing behavior and swaps implementations behind it; that can ease gradual migration without routing every request through a separate proxy. Compare migration risk, dual-running cost, reversibility, and final operational shape. Keep the old implementation only as long as it adds recovery value; indefinite duplication can become permanent architecture.

Prevent compatibility windows from becoming forever

A common migration failure is adding a new field but never removing the old one because no one knows whether a consumer remains. Instrument old-field reads, client versions, and legacy route usage. Set an end date and owner for compatibility. During rollout, ensure rollback code can still interpret data written by the new version. If a migration changes semantics, a simple schema compatibility check is not enough; validate business invariants and sample outputs. Keep a kill switch to stop new traffic but do not rely on it if data has already diverged.

Deployment and database recovery must be coordinated. A rolling deployment can run old and new binaries simultaneously, so both need compatible schemas. A blue-green deployment can still fail if writes go to one database and reads from another without replication guarantees. If dual-run comparisons are asynchronous, account for lag before declaring parity. After cutover, a rollback may need to replay changes in the reverse direction or route read-only traffic to the old path. Test these paths before the final migration step. Capture operational evidence, not just successful unit tests: latency, data parity, incident rate, support reports, and ability to restore.

When evolution is less valuable than keeping a stable system

Do not refactor a stable component only to match a fashionable architecture. Change has risk and consumes capacity that could address a user problem or reliability defect. If a module boundary is working and its ownership is understood, keeping it may be better than a costly extraction. Do not introduce a generic plugin framework until multiple real variations exist. Premature abstraction can make simple changes harder and constrain later learning.

Conversely, do not hide structural risk behind 'it works.' A component that blocks every release, has no restore path, or requires a single expert may justify focused evolution even when current traffic is low. Fitness functions should measure a genuine quality attribute and not become arbitrary gates. A migration is a poor choice when no team can operate both old and new paths, when data semantics are unknown, or when rollback is not possible and the product has no maintenance window. Reduce uncertainty first through instrumentation, tests, and a bounded prototype.

Senior questions for an evolution proposal

Ask what observed constraint is being addressed and what evidence supports it. Is the pain due to scale, ownership, reliability, or code comprehension? Could a module boundary, query optimization, or capacity change solve it with less operational cost? What is the smallest reversible step? Which old and new contracts coexist, how long is the compatibility window, and how will consumers be discovered? Does rollback remain safe after new data is written? Who owns dual-run alerts and the final removal?

Review migration evidence and consequences. What parity checks compare outputs, what sample size detects meaningful defects, and which SLI must not regress? What is the backfill rate limit, storage cost, and effect on production capacity? How do privacy and permissions map across old and new systems? What fitness function prevents the same coupling from returning? A senior answer accepts that architecture is an ongoing set of hypotheses and gives a practical path to validate or reverse the decision, instead of claiming the new diagram is inherently superior.

Terms in plain language

Fitness function
An automated or repeatable check that evaluates an architectural characteristic against an intended threshold.
Strangler migration
A gradual replacement that routes selected behavior to a new implementation while the old system remains available.
Expand-contract
A schema or API migration that first adds compatible capability, transitions consumers, then removes obsolete behavior.

Preparing practice controls…

Check your understanding

These checks explain concepts. They do not measure architecture seniority or update readiness.

1. What is a fitness function in evolutionary architecture?
2. Why use expand-contract for a schema change?

Design independently

A legacy service owns a report endpoint that is slow and tightly coupled to its database. Propose a gradual replacement with a new read model, while preserving correctness, rollback, and service availability.

Hints, not a solution
  • Instrument the user outcome before optimizing.
  • Use compatibility and shadow comparison before directing traffic.
  • Define what rollback means after new data has been written.

0 / 20,000 characters · Not saved

Your learning notes

Sign in to save

Marking a lesson read and reviewing an exercise are separate actions. Neither implies mastery. Saved work is account-owned; saves are explicit and do not queue offline.

References and boundaries

Primary documentation supports the mechanisms described. It does not certify these hypothetical architectures, prices or sizing assumptions. Review platform-specific behavior before implementation.

Martin Fowler: Strangler Fig Application

Primary author article describing incremental replacement around an existing system; it is a migration pattern, not an automatic fit.

Martin Fowler: Foreword to Building Evolutionary Architectures

Primary author discussion of small architectural changes, feedback loops, and fitness functions; the linked book contains the broader treatment.

Back to curriculum