Migrating from a Legacy System to Microservices Without Documentation or Full Control

How to replace a legacy system you can't fully read, change or switch off: learn its real behavior first, route around it with a strangler facade, and prove the new services match the old ones before you cut over.

Migrating from a Legacy System to Microservices Without Documentation or Full Control

Picture a company whose online shop has run for twelve years on a single application. The original authors left long ago. The wiki describes a version of the system that no longer exists. One module was written by a vendor and ships as a compiled library nobody has the source for. And yet the shop processes orders every day, and the business says the same thing it said last year: "it works, don't break it."

Now someone writes "migrate to microservices" on the roadmap.

This article follows that hypothetical shop through the parts of a migration that the usual diagrams skip: not knowing what the system really does, not being allowed to change it, and having to beat something that has been battle-tested for years. If you're still deciding whether microservices are the right target, start with Microservices Architecture and Modular Monolith or Microservices? A Framework for Deciding Without Dogma. Here we assume the decision is made and ask how to survive it.

The Rewrite That Looked Like a Plan

The first instinct is the clean slate: build the new system next to the old one, and switch over when it's ready. It's tempting because it promises to leave the mess behind.

It fails for a reason that has nothing to do with code quality. While the new system is being built, the old one keeps changing: bug fixes, pricing rules, a regulatory tweak. The target moves. The team ends up maintaining two systems and finishing neither, and the switch-over becomes one large, irreversible event with no way to test it against real traffic.

The alternative has a name: the strangler fig, described by Martin Fowler in Strangler Fig and documented in the Azure Architecture Center. Like the vine that grows around a tree, the new system wraps the old one and replaces it piece by piece, while the old one keeps serving users. Every step is small and reversible. That property is what makes everything else in this article possible.

But a strangler needs to know where to cut. And for that, the shop first has to answer an uncomfortable question.

What Does the Old System Actually Do?

With no reliable documentation, the source of truth is the running system. The code tells you what it can do; production tells you what it does. Those are not the same list.

The team starts by listening, in roughly this order:

  1. Capture real traffic. Access logs, API gateway logs or a proxy in front of the legacy app show which endpoints are called, how often, and with what payloads. Endpoints that nobody has called in a year are candidates for deletion, not migration.
  2. Read the database as a contract. Tables, foreign keys, triggers and stored procedures often hold business rules that never made it into application code. A trigger that decrements stock when an order is inserted is a feature, even if no developer remembers writing it.
  3. List the hidden consumers. Nightly jobs, spreadsheets that query the database directly, a partner who calls an undocumented endpoint. These are the clients that break silently.
  4. Write characterization tests. Michael Feathers calls tests that record what the code does today, right or wrong, characterization tests (from Working Effectively with Legacy Code). You send known inputs, save the outputs, and from then on any change in behavior is visible.
Characterization tests don't say the legacy behavior is correct. They say it is the behavior your customers currently depend on. Whether a quirk is a bug or a feature is a business decision, and it's much cheaper to take it before the migration than after.

At the end of this phase the shop has something it never had: a written, executable description of its own system. Only now can it choose what to extract first.

Cutting Where You Can't Edit

Here is the second problem. Suppose the shop wants to move payments into its own service. The obvious step is to change the legacy code so it calls the new service instead of its internal payment module. But the team can't: the module is a vendor binary, or the release process for the legacy app takes months, or nobody dares touch the file.

When you can't change the inside, you work on the outside. There are three seams that don't require editing the legacy code:

  • The edge. Put a facade, such as a reverse proxy or API gateway, in front of the legacy app. Initially it forwards everything. Then, route by route, it sends specific requests to the new service. Users see the same URLs; the facade decides who answers.
  • The data. If the new service needs data the legacy database owns, don't reach into it from the new service. Capture changes with change data capture or an outbox-style export and feed them to the new service, so the legacy schema stays an implementation detail.
  • The translation layer. The legacy system speaks its own dialect: odd status codes, a customer record with forty columns, dates stored as strings. An anti-corruption layer, a term from Domain-Driven Design, translates between that dialect and the clean model of the new service. Without it, the legacy design leaks into every new service and you've rebuilt the old system in smaller pieces.
# Illustrative gateway rules: the facade owns the routing decision
routes:
  - path: /api/payments/**
    target: payments-service   # new
  - path: /**
    target: legacy-app         # everything else, unchanged

The facade also gives the shop its safety net. If the new payments service misbehaves, rolling back is a routing change, not a deployment.

The first service is now running behind the facade. The next question is the one the business actually cares about: is it as good as what it replaced?

Beating a System That Has Twelve Years of Proof

Legacy systems carry an advantage that is easy to underestimate: they have been hit by every odd order, every retry storm, every end-of-month report. The new service is, by comparison, untested in the real world. "Cleaner code" is not an argument that survives the first incident.

So the shop treats parity as a requirement with evidence, in four steps:

  1. Measure the legacy baseline first. Latency percentiles, error rate, throughput at peak, and the cost of running it. You can't claim to match something you never measured, and an old monolith on a local network is often faster per request than a distributed system with network hops.
  2. Define "at least as good" per capability. For payments, correctness and idempotency matter more than raw speed. For product search, latency matters more. Write these down as service level objectives (SLOs) before building.
  3. Run in shadow mode. The facade sends each real request to the legacy system, which answers the user, and a copy to the new service, whose answer is only recorded. Compare the two responses. Differences are either bugs in the new service or undocumented behavior in the old one, and both are worth finding before any customer is affected.
  4. Shift traffic gradually. Use feature flags or weighted routing: a small share of traffic, then more, watching the SLOs at each step. The legacy path stays alive until the new one has held for a full business cycle, including the awkward moments like month-end.

Shadowing has costs worth stating. Duplicated requests must not duplicate side effects, so a shadowed payment call needs a "dry run" mode or a sandbox. And you need real observability on both sides before any of this works: tracing, metrics and logs you can correlate.

What This Costs You

A migration like this is slower and more awkward than a rewrite on paper. Be honest about the bill:

  • Two systems at once. For a long period you run, patch and secure both. The legacy system doesn't get cheaper while you replace it.
  • A permanent-looking facade. The gateway and the anti-corruption layer are extra components that must be operated. Some will outlive the migration.
  • Distributed-systems complexity arrives with the first service, as described in Microservices Architecture: network failures, versioning, monitoring across services.
  • Not everything should move. Some modules are stable, rarely change and have no scaling problem. Leaving them in the legacy core, behind the facade, can be the right final state.

It depends on the system, but a common outcome is a smaller legacy core that stays, surrounded by a handful of services that earned their independence.

Conclusion

The shop at the start believed its problem was the old technology. The harder problems turned out to be missing knowledge, restricted access and a high bar for proof. Each one has a practical answer: learn the real behavior from production, work through the edge, the data and a translation layer instead of editing the untouchable, and treat parity with the legacy system as something you measure, not assume.

If you're facing a migration like this, a concrete first step is small: put a proxy in front of the legacy app, forward everything, and start reading the logs. You'll learn more about your system in a week than the wiki has told you in years.