The first annual architecture review left two findings that could not be resolved with a task. One said that RouteManager's technical debt is not recorded: we know it exists, not how much it costs. The other, that the most expensive decision is still open: what to do with the core, which consumes 64% of the cost in a data center, with a deadline that expires in September 2027. And both rest on a question the whole program takes for granted: how do you replace, piece by piece and without stopping it, a ten-year-old system that bills €140,000 a day? Almost no architect works on empty ground. The usual thing is to inherit a system that works, that sustains the business, and that nobody dares to touch. In this last lesson of the module you will learn to measure technical debt and decide which of it gets paid, to choose a modernization strategy for each piece, and to apply the patterns that make it possible to change a system while it keeps running.

Contents

  1. What technical debt is
  2. Types of debt
  3. Making it visible: the debt register
  4. Payment strategies
  5. Legacy systems: why they persist and what risks they carry
  6. Modernization strategies: the "Rs"
  7. Gradual migration patterns
  8. Why total rewrites fail
  9. RouteManager's debt register
  10. ADR-001 in practice: the extraction of Tracking
  11. The migration of the core to the cloud

  1. What technical debt is

Technical debt is the future cost taken on by choosing a faster or cheaper solution today instead of the right one. The metaphor is financial, and it works because it has the same two parts as a loan:

  • The principal: what it would cost to do it properly now. It is the work of eliminating the debt.
  • The interest: what it costs extra, every month, to live with it. Lost hours, errors, slowness, risk.

Three ideas follow from the metaphor:

  • Going into debt is not bad in itself. A company takes out a loan to reach a market sooner. A team takes a shortcut to make it to a peak season. What is bad is not knowing how much is owed.
  • The interest is always paid, like it or not. It does not appear on any bill: it is paid in the form of changes that take three times as long.
  • Debt that is not paid grows, because the new is built on top of the flawed.

Not all debt is born the same way. A widely used quadrant classifies it with two questions: was it taken on knowingly? And with good judgment?

Prudent Reckless
Deliberate "We deliver it this way to make the peak season and fix it in January; it is written down" "There is no time to design"
Inadvertent "Now that we know the problem, we know how we should have done it" "What is a layered architecture?"
  • Deliberate and prudent debt is the only kind that deserves to be called a decision. It has a reason, an owner, and a date. At Rutaverde it takes the form of a recorded exception.
  • Inadvertent and prudent debt is inevitable: you learn by building. Nobody designed the 6,000-line shipments class; it grew.
  • The two reckless kinds are fought with training, review, and fitness functions, not with a register.

One clarification: not everything that is annoying is technical debt. A defect is a defect, and a missing feature is a missing feature. Debt is whatever makes future changes more expensive.

  1. Types of debt

Type What it consists of Example in RouteManager
Code Duplication, complexity, confusing names The 6,000-line shipments class
Architecture Improper dependencies, broken boundaries, coupling Reports reads everyone's tables; the synchronous SMS inside the delivery confirmation; the API exposes internal names
Infrastructure Environments set up by hand, unversioned configuration The 37-step deployment; app-02, the standby server that was never tested
Testing Lack of automated tests; fear of change The manual regression before every deployment
Documentation Knowledge only in people's heads The design decisions known to two veterans
Obsolescence Unsupported versions of languages, databases, and systems The Java runtime, PostgreSQL, the minimum Android version
Security Missing or weak controls The single database user

Architecture debt is the most expensive, because its interest is paid by every team on every change. Obsolescence debt is the most treacherous: it costs nothing for years, and one day the patch you need does not exist.

  1. Making it visible: the debt register

Debt that is not written down cannot be prioritized, and it always loses against a business request that is. The technical debt register has one row per debt, with six pieces of data:

Data Question
Description and type What is it and where is it?
Interest How much does it cost per month to live with it? In hours, or in risk
Principal How much does it cost to eliminate it? In weeks of one person
Risk What can happen if it is not paid? On the scale of 1 to 9
Dependencies What does it block?
Owner Who answers for it?

The interest is the hard figure, and the most valuable. It is estimated by asking the teams: how many hours did you lose last month because of this? Precision is not needed; an order of magnitude is.

With interest and principal you calculate the payback period: how many months of interest equal the cost of paying off the debt.

  • Payback period, in months = principal in hours / interest in hours per month

A debt that pays back in eight months is an excellent investment. One that pays back in ten years is not; unless its risk forces the issue.

Prioritization

The payback period is not enough, because it ignores risk and dependencies. Rutaverde orders with three rules, in this order:

  1. First, whatever has a high risk or a date. Obsolescence does not wait.
  2. Next, whatever blocks the program. A debt on the critical path is worth what the path is worth.
  3. The rest, by payback period, from shortest to longest.

And a negative rule, as important as the others: do not pay the debt of what is going to be retired. Cleaning up the code of the monolith's Tracking module, which will disappear in October, is throwing money away.

  1. Payment strategies

Strategy What it consists of Useful for Risk
Reserved capacity A fixed percentage of each cycle's capacity is devoted to debt The steady flow of small and medium debts That the percentage is the first thing sacrificed
Boy Scout rule Leave every file you touch a little better than you found it Code debt, continuously and without planning That cleanup changes get mixed with functional ones and make review harder
Dedicated initiative A project with scope, deadline, and owner Large, indivisible debts: a version upgrade, a migration That it turns into a rewrite
Pay as you pass through The debt of an area is settled when the program has to work in it Debt that lies in the path of something planned That it lengthens the estimates without anyone having foreseen it
Do not pay It is accepted explicitly What is going to be retired; what is stable and nobody touches That "nobody touches it" stops being true

They are not alternatives: they are combined. Reserved capacity is the foundation, because it is the only one that does not depend on goodwill. The usual values are between 15% and 25%. Below that, debt grows faster than it is paid.

Two conditions make the reserve survive. The first, that it has been approved by whoever prioritizes the business: at Rutaverde, Daniel accepted it when he approved the roadmap. The second, that it is measured: it is on the scorecard, with 15% as the floor.

  1. Legacy systems: why they persist and what risks they carry

A legacy system is not an old system: it is a system the business depends on and that is difficult or risky to change. It can be three years old.

They persist for good reasons:

  • They work. RouteManager processes 40,000 shipments a day. Ten years in production are ten years of edge cases resolved.
  • They contain business rules that are not written down anywhere else. How a shipment returned twice is handled, what happens to a route on a local holiday.
  • Replacing them is expensive and risky, and the benefit cannot be seen from outside: the user expects everything to stay the same.
  • Everything else has been built around them: integrations, reports, working habits.

And they accumulate known risks:

Risk In RouteManager
Obsolescence with no security patches The Java runtime
Dependence on a few people The two veterans
Rigidity: every change is slow and risky 38 days of waiting and a 33% failure rate per deployment
Difficulty attracting and retaining people Nobody wants to work with ten-year-old technology
It does not scale with the business The outage on the last Black Friday

The right attitude toward a legacy system is respect: it represents accumulated knowledge, and the task is not to destroy it, but to make it evolve without losing what it knows.

  1. Modernization strategies: the "Rs"

For each system, or each part of it, there is a range of options usually presented as a list of words beginning with R:

Strategy What is done Effort and risk When to choose it
Retain Nothing, for now None It works, it changes little, and there is no reason; or it depends on another decision
Retire It is switched off Low Nobody uses it anymore, or something else covers its function
Rehost It is moved as is to another infrastructure Low Leaving a site is urgent; there is no time for more
Replatform It is moved with bounded changes to take advantage of the platform: managed database, autoscaling Medium The benefit of the cloud is wanted without touching the logic
Refactor or rearchitect The internal structure is changed, preserving the function High The current architecture prevents a requirement from being met
Replace or repurchase It is substituted by a product or a service Medium; high in migrating data and habits The function does not differentiate the business and exists on the market

The decision is made piece by piece, not for the system as a whole. Applied to Rutaverde, the table gathers what we have already decided over four modules:

Piece Strategy Decision
Tracking and Notifications modules Rearchitect: they are extracted as services ADR-001
The other six modules Refactor inside the monolith ADR-001
In-house sign-in and passwords Replace with an identity service ADR-009
Delivery photos on the NAS Replatform: object storage ADR-010, ADR-014
app-02, the standby server Retire ADR-004
Accounting ERP Retain —
The core: monolith and database in the data center To be decided Section 11

Two common errors of judgment: believing that rearchitecting is always the most professional choice, when it is the most expensive and is only justified if a requirement demands it; and believing that rehosting is modernizing, when it only moves the problems somewhere else.

  1. Gradual migration patterns

Once the strategy is decided, what remains is how to execute it without stopping the business. These patterns share one principle: the old system and the new one coexist for a time, and traffic is moved over little by little, with a way back at every step.

The strangler fig pattern

It takes its name from the strangler fig, a plant that grows around a tree until it replaces it. A facade is placed in front of the legacy system and receives all the requests. At first it passes them all to the old system. Each time a function is rebuilt outside, the facade diverts the corresponding requests to it. The old system slims down until it can be retired, or until it is left at a size that is easy to live with.

flowchart TB
    U["Users"] --> F["Facade: decides where each request is sent"]
    F -->|"what has not been migrated yet"| L["Legacy system"]
    F -->|"what is already migrated, in a growing percentage"| N["New service"]
    L --> DL[("Data of the legacy system")]
    N --> DN[("Data owned by the new service")]
    L -->|"events or synchronization"| N

Its conditions:

  • There must be a point through which all traffic passes. At Rutaverde it already exists: the managed edge and the load balancers.
  • There must be a seam: a boundary along which a function can be separated. If it does not exist, it has to be created first inside the old system.
  • The data is the hard part. Diverting requests is simple; making sure the new service has the right data is not.
  • You have to finish. A half-done strangler fig leaves two systems to maintain forever.

The anti-corruption layer

The legacy system has its own model: its names, its codes, its quirks. If the new service adopts them, it inherits the debt. The anti-corruption layer is a translator placed at the boundary: it converts the old model into the new contract, so that the new service never sees the inside of the old one.

At Rutaverde, the translator is the outbox publisher. Inside the monolith, the statuses and the fields have the internal names that the API was unintentionally exposing. What goes out is ShipmentStatusChanged, version 1, with the five canonical statuses. Tracking does not know what a column in db-01 is called, nor does it need to.

Branch by abstraction

It is used to replace something inside a system without stopping deployments or maintaining a separate code branch for months. It has four steps:

  1. An abstraction, an interface, is introduced in front of what is to be replaced.
  2. All the code switches to using the interface, which for now has only the old implementation.
  3. The new implementation is written, behind a feature flag turned off.
  4. The flag is turned on gradually and, at the end, the old implementation is removed.
interface TrackingQuery:
    get_status(code) -> ShipmentStatus

implementations:
    LocalQuery          reads the monolith's tables                      # the usual one
    ShadowQuery         answers with the local one and, in the background,
                        asks the new service and logs the differences
    RemoteQuery         calls the Tracking service

configuration:
    tracking.implementation = local | shadow | remote                   # feature flag
  • The interface is the seam that the strangler fig pattern needed and that did not exist.
  • Each implementation is deployed to production turned off, weeks before it is used. This is what the definition of done allows: deployed, or behind a feature flag.
  • The feature flag is configuration, not code: changing it does not require a deployment, and neither does undoing it.

Parallel run and comparison

Before trusting the new service, it is made to work in shadow mode: it receives the same real requests as the old one, but its responses are not delivered to anyone. They are compared with those of the old one, which is still the one that answers. It is the ShadowQuery implementation from the previous block.

Its value is enormous: it tests the new system with real traffic, with its edge cases, at no risk to any user. Its precautions:

  • Only for reads, or for operations without side effects. Duplicating a write would create two shipments, or send two SMS messages.
  • You have to define what a difference is. If the new service is eventually consistent, a response that lags by a few seconds is not an error.
  • The exit criterion has to be set in advance: what rate of differences, for how long, allows moving forward.

Data migration

It is the highest-risk part of any migration, and it has five phases:

Phase What is done Main precaution
Initial load The existing data is copied to the destination Do not overload the source; it is taken from a replica
Continuous synchronization Later changes are propagated to the destination: through events, or through replication Watch the lag
Verification Source and destination are compared: counts, checksums, sampling Automate it and repeat it
Cutover The destination becomes the source of truth Stop writes at the source before opening the destination; never two primaries
Rollback The way back, in case something fails Decide beforehand until when it is possible; from then on, there is only fixing forward

The key concept is the point of no return: the instant from which the destination has accepted data that the source does not have. A good plan postpones it as long as it can, for example by keeping a reverse synchronization for a few weeks, and puts in writing who decides to cross it.

  1. Why total rewrites fail

Faced with a legacy system, the temptation is always the same: throw it away and do it properly from scratch. It almost never turns out well, and for reasons that repeat:

  • The old system is the only complete specification, and nobody has read all of it. The rewrite rediscovers every edge case in production, one by one.
  • The target moves. The business does not wait two years: the old system keeps receiving changes, which have to be made twice.
  • There is no value until the end. For the whole of the rewrite you pay double and deliver nothing. It is the big bang we talked about when planning.
  • The cutover is a leap without a net. All the risk is concentrated in one day.
  • It is always underestimated. What can be seen of the old system is a fraction of what it does.
  • The same habits produce the same debt. If the way of working does not change, the new system will look like the old one in three years.

It is what we ruled out in ADR-001, when the option of rewriting in microservices got the lowest score and a 1 on risk. The gradual path is slower on paper and faster in reality, because it gets there.

  1. RouteManager's debt register

In February 2027, Marta and the three teams build the register the annual review found missing. The interest figures are the teams' estimates, in hours per month; the principal, in weeks of one person.

Id Debt Type Interest Principal Risk Destination
TD-01 Unsupported Java runtime Obsolescence 30 h/month 40 9 Debt capacity; dedicated initiative
TD-02 PostgreSQL on db-01: end of support in December 2027 Obsolescence 0 8 6 Debt capacity
TD-03 6,000-line shipments class Code 60 h/month 30 4 Debt capacity
TD-04 Minimum Android version without patches Obsolescence 10 h/month 6 6 Debt capacity
TD-05 Reports reads other modules' tables Architecture 25 h/month 12 4 Debt capacity
TD-06 37-step manual deployment Infrastructure 40 h/month — 6 Program, phase 0
TD-07 Manual regression before every deployment, for lack of automated tests Testing 48 h/month 24 6 Debt capacity
TD-08 Undocumented design decisions Documentation 20 h/month 4 6 Debt capacity
TD-09 Synchronous SMS inside the delivery confirmation Architecture 15 h/month — 6 Program, phase 3
TD-10 Single database user Security 0 — 9 Program, phases 1 to 3
TD-11 The merchant API exposes internal names Architecture 12 h/month 10 3 Debt capacity, with ADR-003
TD-12 Calls to the maps provider with no timeout Code 5 h/month 1 6 Debt capacity

The first reading is the sum. The interest of the twelve rows comes to 265 hours a month: 3,180 hours a year, the work of almost two of the 22 developers devoted solely to living with the debt. And that is without counting the risk, which is not measured in hours.

Three of the twelve are paid by the program, because what it builds eliminates them. For the other nine, the payback-period calculation:

HOURS_PER_WEEK = 40
debt = [
    # (id, description, interest in hours per month, principal in person-weeks, risk from 1 to 9)
    ("TD-01", "Unsupported Java runtime", 30, 40, 9),
    ("TD-02", "PostgreSQL on db-01 near end of support", 0, 8, 6),
    ("TD-03", "6,000-line shipments class", 60, 30, 4),
    ("TD-04", "Minimum Android version without patches", 10, 6, 6),
    ("TD-05", "Reports reads other modules' tables", 25, 12, 4),
    ("TD-07", "Manual regression for lack of automated tests", 48, 24, 6),
    ("TD-08", "Undocumented design decisions", 20, 4, 6),
    ("TD-11", "The API exposes internal names", 12, 10, 3),
    ("TD-12", "Maps provider with no timeout", 5, 1, 6),
]
for debt_id, name, interest, principal, risk in debt:
    if interest > 0:
        months = principal * HOURS_PER_WEEK / interest
        payback = f"{months:5.1f} months"
    else:
        payback = "         n/a"
    print(f"{debt_id} interest {interest:>2} h/month | principal {principal:>2} | "
          f"payback {payback} | risk {risk}")
print("Total principal:", sum(d[3] for d in debt), "person-weeks")
  • Each row of debt is one from the register, with its three numbers.
  • The payback period converts the principal to hours, multiplying by 40, and divides it by the monthly interest.
  • The condition interest > 0 handles the case of TD-02: a debt that today does not cost a single hour, and whose only cost is the risk.
TD-01 interest 30 h/month | principal 40 | payback  53.3 months | risk 9
TD-02 interest  0 h/month | principal  8 | payback          n/a | risk 6
TD-03 interest 60 h/month | principal 30 | payback  20.0 months | risk 4
TD-04 interest 10 h/month | principal  6 | payback  24.0 months | risk 6
TD-05 interest 25 h/month | principal 12 | payback  19.2 months | risk 4
TD-07 interest 48 h/month | principal 24 | payback  20.0 months | risk 6
TD-08 interest 20 h/month | principal  4 | payback   8.0 months | risk 6
TD-11 interest 12 h/month | principal 10 | payback  33.3 months | risk 3
TD-12 interest  5 h/month | principal  1 | payback   8.0 months | risk 6
Total principal: 135 person-weeks

The result shows why the payback period cannot be the only criterion. By hours, the Java upgrade is the worst investment on the list: more than four years to pay back. And it is the first one that has to be paid. Applying the three rules:

Order Debt Why in that position When
1 TD-12, maps timeout High risk and one week of work: there is no reason to wait February 2027
2 TD-01, Java Risk 9; exception EXC-001 until 30 June; it blocks the multi-instance monolith January to May 2027
3 TD-02, PostgreSQL It has a date: the six-month rule forces a version upgrade before June 2027. It is done by taking advantage of the failover to db-03 May and June 2027
4 TD-08, documentation Key-person risk; it pays back in 8 months February and March 2027
5 TD-07, tests Without tests, everything else is riskier; it lowers the change failure rate March to September 2027
6 TD-05, Reports It blocks the schema per module; exception EXC-002 until 31 October June to October 2027
7 TD-04, Android Risk on the devices; it requires replacing about 60 of them, €15,000, charged to the program's contingency Second half of 2027
8 TD-03, shipments class The highest interest; it needs the tests from TD-07 first From September 2027
9 TD-11, internal names in the API Low risk; it requires versioning the API and notifying the merchants 2028

The capacity adds up: four people for about 44 working weeks are 176 person-weeks a year. What is planned for 2027, everything except TD-11, adds up to 125. That leaves 51 for the debt that will appear, which always appears.

# ADR-026: Technical debt management

Status: Accepted
Date: 2027-02-11
Participants: architecture board; Daniel (business)

## Context
The annual review (AR-10) found that RouteManager's debt was not
recorded. Now estimated, its interest is 265 hours a month.

## Options considered
A. Pay it when it gets in the way.
B. A cleanup project before starting the program.
C. A prioritized register and permanently reserved capacity.

## Decision
We will adopt option C. Debt register in section 11 of the dossier,
with interest, principal, risk, and owner; quarterly review at the
board. Reserved capacity of 4 people out of 22, with a floor of 15%.
Priority: high risk or a date; next, what blocks the program; next,
payback period. The debt of what is going to be retired is not paid.
New deliberate debt is recorded on the day it is taken on, as an
exception with an expiration date. Boy Scout rule, with cleanup
changes kept separate from functional ones.

## Review
Trigger: total interest above 300 hours a month, or devoted capacity
below 15% for two consecutive quarters.

## Consequences
Positive: debt competes with requests using figures. Negative: four
fewer people for new features.
Risks: unreliable interest estimates at the beginning.
Cost: €15,000 in devices, charged to the contingency.

  1. ADR-001 in practice: the extraction of Tracking

A year ago, ADR-001 decided to extract Tracking. The roadmap gave it dates: 21 weeks from 5 April 2027, and milestone M2 on 15 October. Now we can say how, by combining the four patterns.

Step Weeks What is done Pattern Real traffic on the new service Rollback
1. Seam 1 and 2 All the monolith's tracking reads go through the TrackingQuery interface. Nothing changes for anyone Branch by abstraction 0% Not needed
2. Events 3 to 7 Outbox and publisher in the monolith; event-bus in the cloud. Events are published that nobody consumes yet Anti-corruption layer 0% Turn off the publisher
3. Service and data 8 to 13 Tracking is deployed. Initial load from the db-02 replica with the shipments in progress and those delivered in the last 90 days. From then on, it is fed by events Data migration 0% Delete and reload
4. Parallel run 14 to 17, from 5 July Flag set to shadow: the monolith answers and, in the background, compares with the new service Parallel run 0%, but it receives 100% in shadow mode Flag set to local
5. Canary 18 to 20, from 2 August The edge diverts 1%, 10%, 50%, and 100% of tracking.rutaverde.example Strangler fig From 1% to 100% Change the weight at the edge: less than 5 minutes
6. Retirement 21 onward After 30 days at 100%, the module's code and tables are removed from the monolith Strangler fig 100% There is none anymore: point of no return

The criteria for moving from one step to the next are set before starting:

tracking_advancement_criteria:
  from_parallel_run_to_canary:
    - real_differences: "< 0.1% of queries, for 7 consecutive days"
    - not_a_difference: "status lagging less than 5 s behind the monolith"
    - new_service_p95: "< 500 ms with 100% of the traffic in shadow mode"
    - propagation_p95: "< 5 s"
    - dlq: "0 unexplained messages"
  between_canary_steps:
    - minimum_duration: "48 hours, including one morning peak"
    - error_rate: "no higher than the monolith's"
    - error_budget: "no burn-rate alert"
  from_canary_to_retirement:
    - days_at_100: 30
    - rebuild_from_events: "tested in pre-production"
    - approval: architecture board
  • not_a_difference applies what ADR-001 accepted as a consequence: tracking is eventually consistent. Without that line, the comparator would flag as an error every query made one second after a status change.
  • minimum_duration includes a morning peak because a step that has only seen the small hours has seen nothing.
  • rebuild_from_events is the condition for crossing the point of no return: before deleting the monolith's data, it must have been demonstrated that the service can be rebuilt without it.
  • The approval of the retirement belongs to the board, because it is the only irreversible decision in the whole table.

Notice the proportion. Out of 21 weeks, the new service serves no user for 17. That is not slowness: the risk is spent in shadow mode, where it costs nothing, and by the time the first 1% of real traffic arrives almost all the surprises have already happened. With Notifications, in phase 3, the scheme will be repeated with one important difference: notifying is an operation with side effects, and it cannot be run in parallel without sending two SMS messages. The parallel run will be done by comparing what each system would have sent.

  1. The migration of the core to the cloud

Warning. The figures in this section are fictitious. The accounting treatment of the assets being retired and the contractual commitments of a data center must be reviewed with the finance department and with legal counsel.

The last decision left open since the first module remains. ADR-002 left the monolith and its database in the data center "in the first phase" and gave 18 months, until 5 September 2027, to decide their fate. It is a level 3 decision.

Why decide now

It would be possible to wait until August. There are three reasons not to:

  • The cost. ADR-018 said so: the hybrid phase is the most expensive, and the option of speeding up the migration was deferred to this decision.
  • The purchases. Phase 1 needs the servers db-02 and db-03. Whether to buy or lease them depends on how long they are going to last.
  • The roadmap. Phase 4 has room reserved and content to be defined.

Deciding the direction early does not force the date to be set early. The decision can have gates: conditions that must be met in order to go ahead.

The options

The "Rs" from section 6, applied to the core. Rearchitecting it into microservices was ruled out in ADR-001, and replacing it with a product makes no sense: route planning is what sets Rutaverde apart. Three remain:

  • A. Rehost. Move the monolith's virtual machines and a self-managed database to cloud machines, with no further changes.
  • B. Replatform onto dr-core. The recovery environment from ADR-019 already defines the monolith as code in the cloud, with a database replica that is always on. It becomes the main environment, with two changes: the database moves to managed PostgreSQL, with a primary, a standby in another zone, and a read replica; and the monolith's instances scale automatically. Sessions in a managed store, and object storage instead of the NAS.
  • C. Wait. Keep the hybrid architecture and decide again in 2029.

The cost

Íñigo estimates the core in the cloud with option B:

Item Annual fixed cost
Compute for the monolith: three instances and the batch one, with scaling in peak season €38,000
Managed PostgreSQL: primary, standby, and read replica €48,000
Managed session store €2,400
Object storage replacing the NAS €6,000
Load balancing and network €8,000
Recovery in a second region, difference over what is already budgeted €7,600
Total €110,000

And what disappears when the data center closes: the €351,000 of the already optimized data center, the €24,000 of db-02 and db-03, and about €15,000 for the private link. In total, €390,000. With the formula from ADR-018:

Hybrid, optimized Core in the cloud, option B
Annual fixed cost €528,300 528,300 − 390,000 + 110,000 = €248,300
Variable cost per million shipments €2,410 €2,710
At today's volume, 14.6 million €563,486: €0.039 per shipment €287,866: €0.020 per shipment
At the target, 73 million €704,230: €0.0096 per shipment €446,130: €0.0061 per shipment

Two results worth underlining:

  • NFR-12 would be met even at today's volume. The break-even point drops from 82,000 to about 39,000 shipments a day. Risk R-06, that growth is delayed, stops being a cost problem.
  • At the target volume, the savings are €258,100 a year.

And one caution, which Marta puts in the note for Daniel without anyone asking her to: of the €390,000, €118,000 is depreciation of hardware already bought. Switching it off does not give that money back. The immediate cash savings in fixed costs are 390,000 − 118,000 − 110,000 = €162,000 a year, and they only reach €280,000 when that hardware finishes depreciating. Presenting the €280,000 as savings from day one would be dressing up the number in the opposite direction from last time.

The matrix

Criterion Weight A. Rehost B. Replatform C. Wait
Total cost over three years 25% 3 4 2
Migration risk 25% 3 4 5
Elasticity: NFR-08 and peak seasons 15% 3 5 1
Effort and fit with the program 15% 4 3 5
Operational load afterward 10% 2 4 2
Reversibility 10% 3 3 5
Weighted total 3.05 3.90 3.35

The calculation for B: 4 × 0.25 + 4 × 0.25 + 5 × 0.15 + 3 × 0.15 + 4 × 0.10 + 3 × 0.10 = 1.00 + 1.00 + 0.75 + 0.45 + 0.40 + 0.30 = 3.90.

  • B wins clearly, 0.55 over the runner-up.
  • The runner-up is waiting, not rehosting. Rehosting is the worst option: it takes on the risk of a migration and is left with a self-managed database and no real elasticity. It moves the problems somewhere else.
  • B gets a 4 on risk, and not a 2, for a concrete reason: it is not a migration that is rehearsed once. Every recovery drill is a rehearsal. By the time the cutover comes, the team will have started the monolith in the cloud at least four times.
  • C has a 1 on elasticity. Waiting means facing the 2028 peak season, with a peak of one million shipments a day, by powering on servers by hand in a data center.

The gates and the cutover

Gate Date Condition to continue
1 May 2027 First technical drill: dr-core starts on a clone of db-dr and passes the smoke tests
2 September 2027 Second drill: measured RTO of 120 minutes or less
3 March 2028 Load test of the core in the cloud: NFR-04 and NFR-07 with measurements, including the 05:00 batch processes
4 Tuesday 13 June 2028 Real failover with return: production runs from the cloud for several days and goes back to the data center. It is the annual drill from ADR-019, extended
Cutover Tuesday 12 September 2028 Definitive failover. It is milestone M4

If gate 4 is not passed, the 2028 peak season is handled from the data center and the cutover moves to February 2029. The committee decides.

The cutover is done in the maintenance window, with the same recovery runbook, rehearsed:

Time Step
02:00 The API responds 503 with Retry-After; the app goes into contingency mode; db-01, read-only
02:10 The replica lag reaches zero; automated verification of counts and checksums
02:20 The cloud database is promoted to primary; db-01 becomes its replica
02:30 The edge switches the origin; smoke tests
02:45 The service is opened
03:30 Decision to continue or go back, with margin for the 05:00 planning
  • Until 02:20, going back is free: reopening the data center is enough, because the cloud has not accepted any writes.
  • After that, the way back exists, but it is another failover. db-01 keeps receiving the changes as a replica: the data center becomes the recovery site, with the roles reversed.
  • The point of no return is not the cutover, but the retirement of the data center, planned for 31 March 2029, once the peak season is over. Until then, Rutaverde pays for both infrastructures for a few more months, in exchange for facing its biggest peak season with a way back.
  • The 03:30 decision is made by Daniel, on Íñigo's proposal, as in a disaster.
# ADR-027: Core migration to the cloud: replatform onto dr-core

Status: Accepted
Date: 2027-02-25
Participants: technology steering committee

## Context
ADR-002 left the monolith and its database in the data center and set
a deadline of 18 months to decide. The core accounts for 64% of the
cost (ADR-018). ADR-019 created db-dr and dr-core in the cloud. NFR-08
is only partly met. The annual review records it as AR-07.

## Options considered
A. Rehost: 3.05.
B. Replatform onto dr-core, with managed PostgreSQL: 3.90.
C. Wait and decide in 2029: 3.35.

## Decision
We will adopt option B. The core will run in provider B's cloud:
monolith instances with autoscaling, managed PostgreSQL in two zones
with a read replica, sessions in a managed store, and object storage
instead of the NAS. Four gates: drills in May and September 2027, load
test in March 2028, and real failover with return on 13 June 2028.
Definitive cutover on 12 September 2028; if gate 4 is not passed,
February 2029. After the cutover, the data center remains as the
recovery site until its retirement, on 31 March 2029. The servers
db-02 and db-03 are leased for 24 months instead of being bought. No
data center hardware or contract is renewed beyond March 2029. Managed
PostgreSQL moves to the "adopt" ring.

## Security
Data affected: all of the core's data (Personal). New boundary: the
core leaves the dc-data zone and moves to cloud-data.
Requires threat modeling: yes, before gate 3.

## Review
Triggers: any gate not passed; estimated cost of the core in the cloud
above €150,000 a year.

## Consequences
Positive: fixed cost of €248,300 against €528,300; NFR-12 is met from
about 39,000 shipments a day; NFR-08 complete; 2028 peak season with
elasticity. Negative: €118,000 a year of outstanding depreciation that
is not recovered; a few more months of double infrastructure.
Risks: migration of 600 GB with a cutover; greater dependence on
provider B, lessened with standard PostgreSQL and our own images.
Pending: an ADR that supersedes the recovery design of ADR-019 before
the data center is retired, with a second EU region.
Cost: €60,000 for the migration, already in the program budget.

With ADR-027, ADR-002 is fulfilled six months ahead of its deadline. And it leaves in plain view, with no disguise, what it does not solve: when the data center is switched off, the recovery site from ADR-019 will cease to exist, and another will have to be designed.

Common Mistakes and Tips

  • Calling everything you dislike technical debt. Debt is what makes future changes more expensive.
  • A debt with no estimated interest. It competes with nothing, and it loses.
  • Prioritizing by payback period alone. Obsolescence and security are not paid in hours.
  • The "cleanup quarter." Stopping the business to clean up never gets approved twice. Reserved capacity does.
  • Paying the debt of what is going to be retired.
  • Rewriting from scratch because the code is ugly. Ugly and tested for ten years is worth more than elegant and never used.
  • Rehosting and calling it modernizing.
  • A strangler fig that never finishes: two systems, twice the maintenance.
  • Comparing operations with side effects in parallel, and sending two SMS messages to every recipient.
  • Migrating data without a rollback plan, or with one nobody has tested.
  • Not saying where the point of no return is, or who decides to cross it.
  • Tip: before any step of a migration, answer two questions: how do I know it went well, and how do I go back if it went badly. If you do not have both answers, the step is too big.

Exercises

Exercise 1

  1. Classify each debt in the quadrant:
    • a) To make the 2027 peak season, the Services team delivers Tracking without the tool for rebuilding from events, and records it as an exception until February 2028.
    • b) A year after designing the events table, the team realizes that a different partition key would have simplified archiving.
    • c) "There is no time for tests; we'll do them later."
    • d) A developer builds a query by concatenating text received from the user, because they do not know about parameterized queries.
  2. Opening a new city costs three weeks of one developer today. Rutaverde wants to go from 6 to 20 cities in 24 months. Making a city configuration only, as P5 asks, costs 16 person-weeks. Calculate the monthly interest and the payback period.

Exercise 2

Choose a strategy, from among the "Rs," for each case, and justify it:

  1. An old RouteManager module that printed delivery notes on paper, and that no warehouse has used for three years.
  2. The payroll system, installed on a server in the data center, which its vendor maintains.
  3. An internal email-sending service, written eight years ago, that does the same thing as the SMS and email provider already under contract.
  4. A dashboard application for senior management, stable, on a data center server that will be switched off in March 2029.

Exercise 3

We are in the second week of Tracking's parallel run. The comparator flags 2.3% of queries with differences. On analysis: 1.9% are statuses lagging between 5 and 9 seconds; 0.3% are shipments that have been in INCIDENT for more than 90 days, which the new service does not know about; and 0.1% show a status earlier than the real one, permanently. Can you move on to the canary? What would you do with each group?

Solutions

Solution 1

  1. a) Deliberate and prudent: there is a reason, a record, and a date. It is worth adding what risk is taken on in the meantime: without that tool, losing db-tracking would force a fallback to its backups. b) Inadvertent and prudent: it was learned by building; it is noted in the register and you assess whether it is worth paying. c) Deliberate and reckless: there is no plan and no record; it is not a decision, it is a habit. d) Inadvertent and reckless, and an injection vulnerability besides: it does not go into the debt register, it is fixed right away, and it is prevented with training and with automated analysis in the pipeline.
  2. That is 14 cities in 24 months: 7 a year. Each one costs 3 weeks, 120 hours: 840 hours a year, 70 hours a month of interest. The principal is 16 × 40 = 640 hours. Payback period: 640 / 70 = 9.1 months. It is one of the best investments in the register, and it is so precisely because the business is going to grow: the same debt, in a company that opened one city every two years, would not be worth paying. The interest depends on how much the flawed thing is used.

Solution 2

  1. Retire. Nobody uses it. First, check that with data: access logs from the last few months, not someone's memory. Every retired module is debt that disappears at no cost.
  2. Replace, moving to the same vendor's cloud version if it exists, or rehost if not. Payroll does not set Rutaverde apart from any other company, and there is no reason to operate that server. Take care with the data migration, since the data is personal and sensitive: it requires Clara and legal counsel.
  3. Retire, after redirecting its uses to the Notifications service. Keeping two ways of sending email doubles the operations work, and the one that does not go through Notifications bypasses the retries and the control of personal data.
  4. Rehost, or retain until the date forces the issue. It is stable and no requirement asks for it to change; the only thing forcing the decision is the closure of the data center. Moving it as is to a cloud machine is enough. Rearchitecting it would be spending where there is no problem.

Solution 3

You cannot move on to the canary. The criterion was less than 0.1% real differences for seven consecutive days, and first you have to see how many of these are real.

  • The 1.9% of statuses lagging between 5 and 9 seconds. The criterion excludes lags of less than 5 seconds, so these count. And they point to something more serious than a difference: propagation is not meeting its target of a p95 below 5 seconds at some time of day. You have to look at when they occur. If they are concentrated in the morning peak, it is the outbox publisher or the consumer, the same kind of clog the load tests uncovered. The cause is fixed; the tolerance is not widened to 10 seconds so that the number works out.
  • The 0.3% of old shipments in INCIDENT. It is a defect in the initial load: the shipments in progress and those delivered in the last 90 days were loaded, and a shipment that has been in INCIDENT for four months is neither one nor the other for the query that was used. The load criterion is corrected, "every undelivered shipment, with no age limit," and the data is reloaded. It is exactly the kind of edge case that only shows up with real traffic.
  • The 0.1% with an earlier status, permanently. It is the most worrying, even though it is the smallest: it is not a lag, it is incorrect data that does not correct itself. The likely causes are a lost event or an event wrongly discarded when checking the sequence. The dead letter queue and the ordering logic are reviewed; until every case is understood, there is no moving forward.

Once the three causes are fixed, the seven-day counter starts over. The parallel run has done its job: three defects found, and no recipient has seen them.

Conclusion

Technical debt is the future cost of today's shortcuts, with a principal that is paid once and an interest that is paid every month. It can be taken on knowingly or unknowingly, with good judgment or without it, and only the first combination is a decision. It is managed by making it visible in a register, with an estimate of what it costs to keep it and what it costs to eliminate it, and by prioritizing it by risk, by what it blocks, and by its payback period; it is paid with reserved capacity, with continuous cleanup, and with dedicated initiatives, and the debt of what is going to be retired is not paid. Legacy systems persist because they work and because they contain knowledge that is nowhere else. For each piece you have to choose among retaining, retiring, rehosting, replatforming, rearchitecting, or replacing, and to execute the choice without stopping the business there are proven patterns: the strangler fig, the anti-corruption layer, branch by abstraction, the parallel run, and a data migration with verification, cutover, and rollback. Total rewrites fail because they concentrate all the risk and all the value in a single day.

At Rutaverde, ADR-026 gives RouteManager's debt a register of twelve entries, whose interest adds up to 265 hours a month, and a payment order that starts with the unsupported Java runtime. The extraction of Tracking now has a script of six steps and 21 weeks, 17 of which the new service spends working in shadow mode. And ADR-027 closes the last decision left open since the first module: the core will be replatformed onto dr-core, with four gates and a cutover on 12 September 2028, which reduces the fixed cost from €528,300 to €248,300 a year and means NFR-12 is met even at today's volume.

This lesson brings Module 5 to an end. We started it with a platform that was designed, measured, and ready to be operated, and with a list of questions no diagram answered. Eight decisions have answered them. ADR-020 established who decides what, with a committee, a board, and a calendar. ADR-021 chose a provider. ADR-022 settled the retention periods with legal counsel. ADR-023 turned the design into a 24-month program, with phases, milestones, a budget, and an honest allocation of 22 people. ADR-024 took the architecture out of the heads of two veterans and put it in a repository. ADR-025 made evaluation a routine. ADR-026 put figures on the debt. ADR-027 decided the fate of the core. Marta and Daniel have played the role we announced for them: none of these eight decisions is a diagram, and without them the nineteen earlier ones would have stayed on paper.

And with it the journey through Rutaverde also comes to an end. For five modules we have followed a single case, because an architecture is only understood by seeing how each decision conditions the next. But a single case carries a risk: mistaking its answers for the method. Rutaverde chose a modular monolith, events with no personal data, a pilot light, and a two-hour RTO because its requirements, its team, and its budget were what they were. With other constraints, the same questions lead to other answers. In Module 6 we leave Rutaverde to verify it. We will see how the same principles and the same tools, measurable requirements, decision matrices, ADRs, threat modeling, unit economics, recovery objectives, are applied in three sectors with very different demands: an e-commerce company, where peaks and conversion rule; a financial services company, where consistency and regulation rule; and a healthcare organization, where privacy and the availability that people depend on rule. After that will come the final project, in which you will be the one designing the architecture.

© Copyright 2026. All rights reserved