API Gateway
Limita la tasa y enruta las llamadas a la API. Pasado su límite, las peticiones fallan como throttled, y cobra por petición.
Esta página aún no está traducida al español.
The API Gateway is one front door that every API call comes through before it reaches your services, as Kong, AWS API Gateway, or Apigee are.
When to place it#
Place it when one App Server type cannot serve every kind, and you want page views and API calls to reach different server groups.
Place it when you want to protect your services from a burst or from abusive clients without turning them away at the WAF. It unlocks with API gateway.
Place it when you want one place to see and cap API traffic.
Skip it as a bot filter. A rate limit caps volume and does not tell a bot from a shopper, so a WAF still belongs in front of it if bots are the problem.
How it works#
Its rate limit caps the Node at a number of requests a second, and the requests past that limit fail as throttled rather than reach your services. A limit of Off lets everything through. It sits after Users and sends each request kind on the Links its route table gives it, adding a hop of its own. That route table is how a Design splits by kind: send page to a server group built for rendering, login to one that will not stall, and media to a CDN. See rate limiting and the token bucket it still wants.
Unlike every other Component, which bills per second of uptime, the gateway bills per request. It is cheap at low volume and expensive at high volume, and it is the Requests line of the bill. Its price is a managed service's real-dollar fee, so the Era cost index does not multiply it. It has one size and a flat capacity of its own, so a Design past that capacity drops requests at the gateway like any other flat-capacity Node.
Options#
| Control | Valores | Cuándo |
|---|---|---|
| Límite de tasa | Desactivado / 100 / 500 / 1k / 2.5k / 5k | Siempre |
| Ráfaga | Tope fijo / Token bucket de 200 | Siempre |
| Autenticación | Los servicios comprueban / Autenticación en el edge | Siempre |
| Coalescencia | Cada lectura sigue / Coalescencia de peticiones | Siempre |
| Rutas | Todos los tipos, o un subconjunto para cada Enlace | Siempre |
Routes: which request kinds each Link carries. Every kind goes on every Link until you turn one off, so a Link set to
loginonly carries logins and nothing else.Rate limit: the requests a second the gateway lets through. Past it, requests fail as
throttledinstead of reaching your services. Off lets everything through.Burst: Flat cap refuses every request over the limit. Token bucket holds a small reserve, so a short burst passes whole while the long-run average still holds. It needs Rate limiting.
Auth: Auth at the edge validates each token once, at the gateway, and the services behind it skip the check. Services check leaves the validation to every service.
Coalescing: merges identical reads that are in flight at once. The busier the gateway, the more it saves.
How it fails#
A limit below your demand throttles real users, and a throttled request earns nothing, so a limit you set must leave room for the traffic you want.
Past its own capacity it drops requests, whatever the rate limit says.
It is a single hop in front of everything, so an overloaded or misconfigured gateway fails every request kind at once.
Instance failure#
Signs: The API Gateway card goes grey and its callout reads "The host under this VM died. It still bills." Requests sent to it are stranded.
Do now: Select the Node and click Replace. It costs Cash and comes back cold.
Prevent: Run a second copy behind a Load Balancer that skips dead hosts. Load balancing and Health checks unlock them.
Certificate expired#
Signs: The Certificate expired banner appears, and every request through the API Gateway fails, as through every other TLS Node.
Do now: Click Renew in the banner.
Prevent: Research Certificate automation and place a Secrets and Certificates Node, which renews the certificates before they run out.
Region outage#
Signs: One region's board goes grey and the API Gateway in it goes down.
Do now: Press Fail over on the banner. It needs Multiple zones and a second open region, and starts the Node again in the nearest other region, cold, for the price of a replacement. Otherwise it comes back when the incident ends: 180 sim seconds in the catalog, 60 once the error budget counts.
Prevent: Research Multiple regions, keep a copy in a second region, and add GeoDNS to send users there.
Tips#
Leave the limit Off until you know your peak, then set it a little above the peak you want to serve.
Watch the Requests line, not just the rate limit, because per-request pricing grows with traffic.
Reglas#
- Cada copia adicional cuesta un 25% más que la anterior.
- Al venderlo se devuelve el 50% de lo que costó su última copia.
- Tiene un solo tamaño.
Funciona con#
Usuarios, Servidor de aplicaciones, Balanceador de carga, WAF, Hub en tiempo real, Secretos y certificados
Investigación siguiente#
Cuando tengas API Gateway, estas Investigaciones se apoyan en ella.