← Previous Chapter: Part 5: Migrating Magento EAV Schema | Series Hub | Next Chapter: Part 7: Phase 2 — Dual-Write CDC →


Answer-first: Phase 1 of the Strangler Fig migration routes catalog read traffic (/products/*, /catalog/*, /search/*) to high-speed Go microservices via Cloudflare Edge Workers while keeping Magento active for checkout. This offloads 82% of server compute load from the legacy monolith with zero downtime.


flowchart TD
    Client["Client Browser / Mobile App"] --> Edge["Cloudflare Edge Worker (Traffic Router)"]
    Edge -->|"/products/* & /search/* (82% Traffic)"| GoCatalog["Go Catalog & Search Service (K8s)"]
    Edge -->|"/checkout/* & /customer/* (18% Traffic)"| Magento["Legacy Magento Monolith (PHP/MySQL)"]

1. Cloudflare Edge Routing Implementation

// cloudflare-edge-router.ts
export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const url = new URL(request.url);

    // Route Catalog & Search to new Go Microservices
    if (url.pathname.startsWith('/api/v1/products') || url.pathname.startsWith('/api/v1/search')) {
      return fetch(`https://catalog-api.example.com${url.pathname}${url.search}`, request);
    }

    // Fallback all other requests (Checkout, Admin) to legacy Magento
    return fetch(`https://legacy-magento.example.com${url.pathname}${url.search}`, request);
  }
};