AWS Lambda vs Cloudflare Workers for a latency-sensitive API gateway. 200M requests/month, P99 target <50ms, currently on ECS Fargate.
Migrate the API gateway from ECS Fargate to Cloudflare Workers using an edge-compute + origin-fetch pattern to...
Decision
Deploy Cloudflare Workers as the API gateway using edge-compute + origin-fetch to existing AWS backends. Workers V8 isolates have zero cold starts (sub-1ms spin-up), edge execution adds <5ms, leaving ~45ms for origin fetch — US-East RTT of 10-25ms fits comfortably. Total cost: ~$500/month versus $6K Fargate (94% savings). Lambda is disqualified: Provisioned Concurrency for 770 peak concurrent instances costs $11K-13K/month (40-60% over $8K ceiling), and without it, Lambda P99 is 800ms — 16x the target. Migrate via Cloudflare DNS with percentage-based traffic splitting (10% → 50% → 100% over 5 days), keeping Fargate as fallback. Critical failure mode: if the gateway calls AWS VPC-internal services, cross-cloud RTT of 15-30ms leaves <20ms for backend processing. Mitigate with Cloudflare Tunnel or public endpoints, and validate backend processing time fits within the remaining budget before full cutover.
Next actions
Council notes
Evidence boundary
Observed from your filing
- AWS Lambda vs Cloudflare Workers for a latency-sensitive API gateway. 200M requests/month, P99 target <50ms, currently on ECS Fargate.
Assumptions used for analysis
- The API gateway primarily performs routing, auth, and lightweight transformation — not compute-heavy processing that would exhaust Workers CPU limits
- Backend services are accessible via public endpoints or can be exposed via Cloudflare Tunnel without prohibitive latency
- Traffic is predominantly US-centric, making the 10-25ms RTT estimate to us-east-1 representative
- The $8K/month cost ceiling is a hard constraint that disqualifies Lambda Provisioned Concurrency
- Current ECS Fargate can remain operational as a fallback during the 5-day migration window
- team size defaulted: standard team (5-10 engineers) (not_addressed)
Inferred candidate specifics
- Deploy Cloudflare Workers as the API gateway using edge-compute + origin-fetch to existing AWS backends. Workers V8 isolates have zero cold starts (sub-1ms spin-up), edge execution adds <5ms, leaving ~45ms for origin fetch — US-East RTT of 10-25ms fits comfortably. Total cost: ~$500/month versus $6K Fargate (94% savings). Lambda is disqualified: Provisioned Concurrency for 770 peak concurrent instances costs $11K-13K/month (40-60% over $8K ceiling), and without it, Lambda P99 is 800ms — 16x the target. Migrate via Cloudflare DNS with percentage-based traffic splitting (10% → 50% → 100% over 5 days), keeping Fargate as fallback. Critical failure mode: if the gateway calls AWS VPC-internal services, cross-cloud RTT of 15-30ms leaves <20ms for backend processing. Mitigate with Cloudflare Tunnel or public endpoints, and validate backend processing time fits within the remaining budget before full cutover.
- Deploy a Cloudflare Workers proof-of-concept that proxies 3-5 representative API routes to the existing Fargate ALB, measure P99 end-to-end latency including origin fetch under synthetic load matching peak traffic patterns (770 concurrent requests), and validate that cross-cloud RTT + backend processing fits within the 50ms budget.
- Branch b003 had the highest confidence (0.82), survived 3 rounds of adversarial review including strengthening in rounds 1 and 2, named specific cost thresholds ($500/month vs $11-13K Lambda), specific latency breakdowns (sub-1ms isolate, <5ms edge, 15-30ms cross-cloud RTT), concrete failure modes (VPC access, backend processing budget), and a specific migration timeline. Reframe branches b006 and b007 raised valid strategic considerations but neither provided actionable recommendations.
- Hybrid Cloudflare Workers + Lambda (80/20 routing split)
- Killed in round 3. Adds Lambda cold start risk for 20% of traffic, increases operational complexity, and total cost of $7.2K/month approaches the ceiling without meaningful latency advantage over pure Workers.
- AWS API Gateway + Lambda@Edge + Global Accelerator (single-ecosystem approach)
- Killed in round 2. Global Accelerator adds significant cost ($0.025/GB + accelerator fees), Lambda@Edge pricing is higher per request at 200M/month scale, and multi-cloud operational overhead was overstated — Shopify runs Workers edge + AWS origin successfully with standard observability tooling.
- Valid strategic consideration (b006) but is a reframe, not an actionable recommendation. The 50ms P99 target and 200M req/month are stated constraints — if most users are near us-east-1, the Workers approach still wins on cost and cold start elimination.
Inferred specifics table
| Value | Kind | Basis | Where introduced |
|---|---|---|---|
| sub-1ms spin-up | threshold | synthetic | chosen_path |
| edge execution adds <5ms | threshold | synthetic | chosen_path |
| leaving ~45ms for origin fetch — | threshold | synthetic | chosen_path |
| RTT of 10-25ms fits comfortably | threshold | synthetic | chosen_path |
| Total cost: ~$500/month versus $6K Fargate | estimate | synthetic | chosen_path |
| 94% savings | threshold | synthetic | chosen_path |
| Concurrency for 770 peak concurrent instances costs | estimate | synthetic | chosen_path |
| instances costs $11K-13K/month | estimate | synthetic | chosen_path |
| 40-60% over $8K ceiling | threshold | synthetic | chosen_path |
| Lambda P99 is 800ms — 16x the target | threshold | synthetic | chosen_path |
| 10% → 50% → 100% over 5 days | threshold | synthetic | chosen_path |
| RTT of 15-30ms leaves <20ms for backend | threshold | synthetic | chosen_path |
| 15-30ms leaves <20ms for backend processing | threshold | synthetic | chosen_path |
| that proxies 3-5 representative API routes to | estimate | synthetic | next_action |
| 770 concurrent requests | estimate | synthetic | next_action |
| 0.82 | estimate | synthetic | selection_rationale |
| Branch b003 had the highest confidence | estimate | synthetic | selection_rationale |
| in rounds 1 and 2 | estimate | synthetic | selection_rationale |
| 82 | estimate | synthetic | selection_rationale |
| $500/month vs $11-13K Lambda | estimate | synthetic | selection_rationale |
Unknowns blocking a firmer verdict
- Actual backend processing time for AWS-internal services is unknown — if complex queries take >20ms, the 50ms P99 budget may be violated when combined with 15-30ms cross-cloud RTT
- Whether the API gateway requires access to AWS VPC-private services (DynamoDB, ElastiCache, SQS) is unstated — this determines whether Cloudflare Tunnel or public endpoints are needed, adding latency and complexity
- The $500/month Workers cost estimate depends on CPU duration staying low; compute-heavy gateway logic (auth, transformation, validation) could push Workers Unbound costs higher
- Geographic distribution of users is unknown — the 10-25ms RTT estimate assumes US-centric traffic hitting US edge nodes; global traffic patterns could differ
- Cost numbers for Lambda Provisioned Concurrency are model-estimated, not sourced from AWS pricing calculator with the specific runtime/memory configuration