Extract microservices from a monolith incrementally — never rewrite everything at once.
# Step 1: Identify bounded context to extract
# Step 2: Build new service alongside monolith
# Step 3: Route traffic via API Gateway
# Step 4: Deprecate monolith code for that feature
# Step 5: Repeat
# Nginx routing during migration
# During: payment -> new service
location /api/payments {
proxy_pass http://payment-service:3001;
}
# Rest stays in monolith
location / {
proxy_pass http://monolith:3000;
}
# After: payment fully extracted
# Remove payment code from monolith