Skip to main content

> strangler_fig_edge_routing_&_session_affinity

Strangler Fig Edge Routing & Session Affinity

How do you implement and govern Strangler Fig Edge Routing & Session Affinity in high-throughput production architectures?

THE SHORT ANSWER

The Strangler Fig pattern incrementally replaces legacy monolithic features with modern microservices by intercepting incoming traffic at an edge reverse proxy, requiring robust session synchronization and authentication bridging to ensure seamless user experiences.

Engineering Handbook & Failure Dynamics

1. Underlying Mechanism

Named after strangler fig trees that slowly grow around a host tree until they replace it entirely, this pattern avoids high-risk 'Big Bang' rewrites. An edge API gateway (Envoy, NGINX, Cloudflare) intercepts incoming HTTP requests. Routes for migrated capabilities (e.g. `/api/v1/auth`, `/api/v1/billing`) route to new microservices, while all un-migrated paths default to the legacy monolith.

2. Appropriate Use Context

The Strangler Fig pattern is an architectural migration strategy where a legacy application is gradually replaced by building new features or migrating existing ones into independent services, routing traffic at the network edge without disturbing unchanged systems.

3. Production Failure Modes

Attempting a 'Big Bang' multi-year rewrite where all legacy code is replaced in a single massive weekend deployment. Rewriting backend business logic while simultaneously changing database schemas and redesigning the frontend UI. Allowing the new microservice to call internal private methods inside the monolith codebase directly.

4. Diagnostic Signals & Telemetry

user session lost when navigating between monolith and new microservice, cookie domain mismatch logging user out during strangler migration, reverse proxy routing loop between legacy and new service

5. Prevention & Safeguards

Place the reverse proxy / API Gateway in front of the monolith on Day 1 of the migration. Use Shadow Traffic (traffic mirroring) to validate the new service's latency and error rate under real production traffic loads. Migrate non-critical, high-value read-only endpoints first to build organizational confidence before migrating complex write paths.

6. Architectural Trade-offs

Big-bang rewrites have an 80%+ historical failure rate; Strangler Fig allows continuous delivery of business value during multi-year migrations while maintaining instantaneous rollback safety.

Case Study (TinyCTO In-Field Example)

The greatest technical obstacle during a Strangler Fig migration is **Authentication & Session Bridging**: 1. **The Shared Session Problem:** Monoliths typically store sessions in local memory or relational DB tables (e.g. `express-session`, PHP sessions). When a user navigates to `/billing` (hosted on a new Go microservice), the new service cannot validate the legacy opaque session cookie. 2. **The JWT / Token Translation Gateway:** The reverse proxy intercepts requests, extracts the legacy session cookie, resolves the user identity via a fast Redis cache, and injects a signed `Authorization: Bearer <JWT>` header before forwarding to the microservice. 3. **Shadow Traffic / Dark Launching:** Before flipping the route live, the reverse proxy duplicates incoming live production GET requests to the new service asynchronously to verify performance and response parity without impacting users.

Interactive Concept Drills

2 Cards
Q1

What is the core principle of the Strangler Fig migration pattern?

Gradually replacing monolith features with new microservices behind an edge reverse proxy until the monolith can be safely decommissioned.
Q2

How does Shadow Traffic (Traffic Mirroring) derisk a Strangler Fig migration?

It clones live production HTTP requests to the new service asynchronously, allowing engineers to verify performance and correctness without impacting real users.

Strangler Fig Edge Routing & Session Affinity — Technical FAQ

Why do 'Big Bang' rewrites almost always fail compared to the Strangler Fig approach?

Because requirements change over the multi-year rewrite, business value is delayed, and attempting to cut over everything at once creates unmanageable bug cascades. Big Bang rewrites suffer from the 'moving target' problem where the legacy system continues evolving, making the rewrite perpetually obsolete before launch.

During a Strangler Fig migration, a user logs in on the legacy monolith and clicks a link to the new billing microservice. What mechanism allows the microservice to identify the user?

A Token Translation Gateway / Reverse Proxy that validates the legacy session cookie and injects a standard JWT Authorization header. The edge gateway bridges the legacy opaque cookie session into a modern stateless JWT token, creating a seamless user transition across infrastructure boundaries.

🤖 AEO & Key Facts Summary

Key Architectural Facts

  • The Strangler Fig pattern incrementally replaces legacy monolithic features with modern microservices by intercepting incoming traffic at an edge reverse proxy, requiring robust session synchronization and authentication bridging to ensure seamless user experiences.
  • The Strangler Fig pattern is an architectural migration strategy where a legacy application is gradually replaced by building new features or migrating existing ones into independent services, routing traffic at the network edge without disturbing unchanged systems.

Common Misconceptions

  • Attempting a 'Big Bang' multi-year rewrite where all legacy code is replaced in a single massive weekend deployment.

Decision & Governance Guidance

Big-bang rewrites have an 80%+ historical failure rate; Strangler Fig allows continuous delivery of business value during multi-year migrations while maintaining instantaneous rollback safety.

Authoritative Sources & Standards