Scrivio Interview library
DesignIntermediate7 min read · updated 12 November 2026

Design a strangler fig migration for a legacy order system, using Spring Cloud Gateway in front of it, where the first function to move is order tracking.

I would first put Spring Cloud Gateway in front of the legacy order system and route everything to it unchanged. Then I would build a new tracking service with its own read model, fed from legacy data by change data capture or events, add a gateway route for the tracking paths controlled by a flag or a percentage of users, compare old and new responses for a while, monitor both paths with a quick switch back to legacy, and repeat for the next function chosen by value and ease.

Why this question is asked

Explaining the strangler fig in general is easy; designing the first real step is where the details matter. Order tracking is a good first function because it is read-only, used a lot and fairly separate from the rest of ordering, so a mistake shows a wrong status rather than losing an order. Interviewers ask this to see whether a candidate can turn the pattern into a concrete architecture with data flow, routing, verification and rollback. In this answer, we will introduce the gateway safely, build the tracking read model, route traffic gradually, compare responses, plan monitoring and rollback, and choose what moves next.

1Putting the Gateway in Front, Changing Nothing

Spring Cloud Gateway is a Spring project for building an API gateway: a service that receives every request and forwards it to a backend according to routes, which are rules made of predicates (conditions such as a path) and filters (changes such as adding a header). Our first release adds the gateway with a single route that sends everything to the legacy system.

This step looks pointless but is the foundation. We move DNS or the load balancer to the gateway, check that every page, API client and redirect still works, and measure the extra latency, typically a millisecond or two. If something breaks, we have learned it while no new code is involved, and rolling back is pointing DNS back to the legacy system.

YAML
spring:
cloud:
gateway:
routes:
- id: legacy-everything
uri: http://legacy-orders:8080
predicates:
- Path=/** # every request still goes to the legacy system

Property names for the gateway have been reorganised in recent releases (for example the server WebFlux and WebMVC variants), so check your version's reference documentation for the exact prefix.

2Building the Tracking Service and Its Read Model

The new tracking service needs order and shipment data, but the legacy database still owns it, because orders are still created and updated by legacy code. So the new service does not write that data; it keeps its own read model, a copy shaped for the queries tracking needs, such as order id, status, carrier, tracking number and the list of status changes with timestamps.

To keep that copy current we use change data capture, CDC for short: a tool such as Debezium reads the legacy database's transaction log and publishes every inserted, updated or deleted row as an event to Kafka. The tracking service consumes those events and updates its own tables. If the legacy system already publishes business events, such as OrderShipped, we can use those instead, which gives cleaner data than raw table rows.

Step throughHow tracking data reaches the new service
Legacy appLegacy DBDebeziumKafkaTracking service
UPDATE shipments SET status = 'SHIPPED'
read change from transaction log
publish row change event
consume event
upsert tracking read model
serve GET /orders/{id}/tracking

6 messages in order. Play them, or step through them one at a time.

The legacy system keeps owning the data; the new service holds a copy shaped for tracking.

Notice that the copy is eventually consistent: a status change appears in the new service a moment after it is committed in the legacy database, usually well under a second. For tracking that is fine, and we measure the lag so we know it stays small.

3Routing Tracking Requests Gradually

Now we add routes for the tracking paths above the catch-all route. We do not switch everyone at once. Spring Cloud Gateway has a Weight predicate that splits requests in a group between routes by percentage, which is a simple way to send, say, 10 percent of tracking requests to the new service.

Java
@Bean
RouteLocator routes(RouteLocatorBuilder builder) {
return builder.routes()
.route("tracking-new", r -> r.path("/orders/*/tracking").and().weight("tracking", 10)
.uri("http://tracking-service")) // about 10 percent of tracking requests
.route("tracking-legacy", r -> r.path("/orders/*/tracking").and().weight("tracking", 90)
.uri("http://legacy-orders:8080")) // the other 90 percent
.route("legacy-everything", r -> r.path("/**")
.uri("http://legacy-orders:8080")) // everything else is unchanged
.build();
}

A weight split is decided per request, so one user may see the new page and then the old one. When a consistent experience matters, we route by user instead: a feature flag service assigns users to the new path, the gateway adds a header or reads a cookie, and a header or cookie predicate picks the route. Either way, the percentage or the flag can change without redeploying the new service.

4Comparing Old and New Responses

Before the new path serves many users, we want evidence that it gives the same answers. A simple way is a comparison filter: for a sample of tracking requests, the gateway, or a small comparison component, also calls the other system in the background, compares the two responses field by field, and records any difference with the order id. Users only receive the response from the route they were assigned.

Differences are expected at first and are useful. Some are bugs in the new service, some are timing because of CDC lag, and some reveal rules hidden in the legacy code, such as a status that is shown differently for a certain carrier. We fix or explain each one, and only when the difference rate is close to zero, apart from known lag, do we raise the percentage.

5Monitoring Both Paths and Switching Back Fast

Both routes get the same dashboards: request rate, error rate, latency percentiles, plus the CDC lag and the comparison difference rate. Alerts fire on the new path's errors or lag. The rollback is deliberately boring: set the weight or flag for the new route to zero, which a configuration change does in seconds, and every tracking request goes back to legacy, which never stopped working.

We keep that switch for a period after reaching 100 percent, for example a few weeks covering a busy sales period. Only then do we delete the legacy tracking code and the old route, which is the moment the legacy system actually shrinks.

Step throughReleasing tracking
  1. Gateway routes 100 percent to legacyno behaviour change
  2. Tracking service live on CDC datadark: no user traffic
  3. Send 1 then 10 percent of trackingcompare responses
  4. Errors, lag and differences acceptable?
    YesyesNoraise to 50, then 100 percent
  5. Keep the switch for a few weeksthen delete legacy tracking code

5 steps in order. Play them, or step through them one at a time.

6Choosing the Next Function

With tracking done, we have a working gateway, a CDC pipeline and a release process, so the next function is cheaper. We pick it by value and ease. Read-heavy functions with clear boundaries, such as order history or notifications, are easy because they can use the same read model approach. Functions that write data, such as returns or order placement, are harder, because ownership of the data must move from legacy to the new service, and the flow of data may need to reverse.

We score each candidate by business value, technical ease and how much it unblocks later steps, and we review that ranking after every move, because what we learn changes the estimates.

Ranking the next functions
FunctionValueEaseNext?
Order historymediumhigh: read-only, same CDC dataYes, next
Notificationshighmedium: events already existSoon after
Returnshighlow: writes data, shared rulesLater
Order placementvery highlow: core writes, paymentsLast

7Follow-up questions

Why not let the new tracking service read the legacy database directly?

It would be faster to build, but it couples the new service to the legacy schema, so every legacy change can break it and the legacy database's load grows with new traffic. A separate read model fed by CDC gives the new service its own schema and lets the legacy database be retired later without rewriting the new service.

What happens when a function that writes data moves?

Ownership of that data moves to the new service. During the switch we either keep both in sync with CDC flowing in the reverse direction, from the new service back to legacy tables that other legacy code still reads, or we make the legacy code call the new service. We avoid both systems writing the same records at the same time.

8Conclusion

In this answer, we designed the first step of a strangler fig migration with Spring Cloud Gateway. We put the gateway in front of the legacy order system with one catch-all route, built a tracking service with its own read model fed by CDC or events, and added tracking routes controlled by a weight or a user flag. We compared old and new responses before raising traffic, monitored both paths with a fast switch back, and ranked the next functions by value and ease.

What to say in the interviewAbout 90 seconds aloud

Open with

First I would introduce Spring Cloud Gateway in front of the legacy order system with a single route that sends everything to it, and release that on its own, so we prove the gateway changes nothing.

Then, if they want more

Then I would build the new tracking service. The legacy database still owns orders and shipments, so the new service keeps its own read model, filled by change data capture with Debezium into Kafka, or from business events if the legacy system publishes them.

Next I add tracking routes above the catch-all: with the Weight predicate I can send, say, 10 percent of tracking requests to the new service, or use a feature flag per user with a header or cookie predicate if users should see a consistent page.

For a period, I compare responses for a sample of requests between old and new and investigate every difference, because that is where hidden legacy rules show up. Both paths have dashboards for errors, latency, CDC lag and difference rate, and the rollback is setting the weight to zero, which takes seconds.

After a few weeks at 100 percent, I delete the legacy tracking code. Then I pick the next function by value and ease, usually other read-heavy parts like order history first, and leave write-heavy functions like order placement for later.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Design a strangler fig migration for a legacy order system, using Spring Cloud Gateway...": https://scrivio-interview-library.netlify.app/architecture/modernization/06b3e8d27f/