Replacing a legacy system in one rewrite concentrates risk into a single large change. The strangler pattern builds new capabilities alongside the old system, then shifts responsibilities in small, reversible steps. section 7.3.2 section 7.6
A practical progression is to:
- Add a routing layer that sends some requests to the new implementation and leaves the rest on the legacy system. section 7.3.2
- Start with internal test traffic, verify behavior against the legacy system, then increase production traffic gradually. section 7.3.2
- Replace one endpoint at a time; if defects appear, route requests back to the legacy implementation. section 7.3.2
Listing 7.9 Strangler Fig approach to isolate legacy payment capabilities
def process_payment(request):
if should_use_new_system(request):
return new_payment_service.process(request)
else:
return legacy_payment_system.process(request)
def should_use_new_system(request):
# Phase 1: Internal test traffic only
if request.headers.get('X-Internal-Test'):
return True
# Phase 2: 1% of production traffic
if hash(request.user_id) % 100 == 0:
return True
# Phase 3: Gradually increase to 10%, 25%, 50%, 100%
return rollout_percentage_for_user(request.user_id) < CURRENT_ROLLOUT_PCTThe payment example shows request routing from internal tests to percentage-based production rollout. section 7.3.2





