11.2 Incremental Replacement (Strangler Fig)
Replace a legacy system step-by-stepThis pattern is based on the Strangler Fig Application originally defined by Fowler [199, later 200], later by Richardson [20, p. 430, 201], Newman [3, p. 79, 189, p. 79], Deenadayalan [202] and Microsoft [203].
Fowler later renamed the pattern to Strangler Fig, as it was commonly shortened to strangler application – which had a violent connotation, different to the original plant-based metaphor [204] – in hopes of strengthening the original intention of the name [199].
In this spirit1, this work primarily refers to this pattern with the more descriptive Incremental Replacement, avoiding the metaphor altogether so as not to depend on the reader’s prior botanical knowledge.
11.2.1 Context
For whatever reason, a legacy system needs to be replaced, but a big bang2 release would bring unnecessary risks.
11.2.2 Solution
Add Gateway Router (see § 4.1) before the legacy and new applications. Initially, the router forwards all requests to the legacy system. Over time, it filters out requests that can be handled by the new system, gradually replacing the legacy system with the new one (see fig. 35).
This spreads both the risk and the development effort over time. Parallel Run [189, p. 79] – i.e., running can ensure the new system emits the same behaviour as the legacy system before switching over.
Once the migration is complete, the router can be phased out, or it can be used as an Anti-Corruption Layer adapter (see § 11.1) for legacy clients.
11.2.3 Related patterns
This pattern can be seen as a message-based temporary Gateway Router (see § 4.1)
For communicating with a legacy system, consider using a Anti-Corruption Layer to isolate legacy domain logic and models (see § 11.1)
11.2.4 Example
ExampleEshop is working on implementing same-day delivery to improve its competitiveness. However, the technical limitations of the old system it uses in manage its warehouses prevent the implementation of this goal. Furthermore, since the original author left, the company lacks the necessary expertise with the system’s legacy technologies to facilitate the needed changes.
The company has decided to implement a new warehouse management system to address this. However, this system is critical to business, and the company cannot afford the risk of a sudden switch. Instead, they decide to implement the new system gradually. They start by first reimplementing enough features to handle same-day delivery. Once this is done, the system is tested in parallel mode to see if it produces the same results as the old system. It is deployed to handle same-day delivery for a select subset of items if it proves stable.
Even though the new system cannot fully replace the old one yet, it already provides business value and can be gradually expanded with more features without time pressure.
11.2.5 Further reading
- Newman’s book on migrating legacy systems to microservices contains many other useful patterns [189, p. 113]