API Gateway cost optimization: reduce requests, bytes, and log spend

API Gateway bills scale with requests and often bytes transferred. The fastest savings come from identifying the dominant driver, then applying targeted fixes that reduce one (or both) without breaking correctness.

Step 0: identify the dominant driver

  • Requests: total requests/month (including retries, health checks, and background jobs).
  • Transfer: average response size over the wire (compressed) multiplied by request volume.
  • Logs: access log ingestion (GB/day) + retention + query scans.

If you don’t know which dominates, model all three with a quick estimate, then validate against a real week of measured usage.

1) Reduce request volume (without losing functionality)

  • Cache hot reads: edge caching (CloudFront) for cacheable GETs, or application caching for authenticated reads.
  • Batch calls: collapse chatty flows (N sequential calls) into fewer endpoints.
  • Avoid aggressive polling: switch to events/streams (SSE/WebSockets) where it fits.
  • Control automated traffic: health checks, bots, integrations, and cron jobs are often a large % of total requests.

2) Reduce bytes transferred (often larger than request fees)

  • Enable compression where safe; model using compressed payload sizes, not raw JSON sizes.
  • Paginate large endpoints and avoid huge default payloads.
  • Move large downloads behind object storage + CDN instead of returning big payloads via the API.
  • Use cache-friendly shapes: stable URLs and query parameters improve CDN efficiency.

3) Stop retry-driven cost spikes

  • Measure retries: track 4xx/5xx rates, timeouts, and client retry counts by endpoint.
  • Fix upstream bottlenecks: slow dependencies cause timeouts and retries (databases, Lambda cold starts, downstream APIs).
  • Use backoff + idempotency: prevents duplicated work and thundering herd patterns.

4) Keep access logs useful (and affordable)

  • Log only the fields you use; large headers and verbose formats inflate GB/day.
  • Keep a slim “always-on” format; enable verbose logging only during investigations.
  • Set retention intentionally; avoid keeping success logs forever by default.

Related: API Gateway access logs cost.

Validate with a cost model

Use API Gateway cost calculator to quantify savings from reduced requests or smaller payload sizes.

Validation checklist

  • Validate requests/month from logs or metrics; include retries and automated traffic.
  • Validate payload size using compressed “over the wire” sizes (not raw JSON).
  • Validate cache hit rate (if using a CDN) and confirm origin request reduction.
  • Compare a real week of cost/usage before and after changes (same traffic seasonality).

Sources


Related guides


Related calculators


FAQ

What's the fastest lever to reduce API Gateway cost?
Reduce request volume and reduce bytes transferred. For many APIs, transfer and retries can dominate more than the per-request fee.
Can retries make API Gateway expensive?
Yes. Timeouts and transient errors trigger client retries and amplify both request volume and transferred bytes. Treat elevated retries as a reliability and cost incident.
Do access logs matter for cost?
They can. At high volume, log ingestion and retention (and query scans) can become a meaningful part of the bill.

Last updated: 2026-01-27