Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

283
Visualizações
AWS API Gateway Throttling not working as expected

I'm trying to enable API Gateway throttling, but it's not working as expected.

I set Default Method Throttling Rate to 1 request per second, and Burst to 1 request.

enter image description here

Then I created a loop in my code to make 10 simultaneous requests to my API endpoint.

for (let i=0; i<10; i++) {
    axios.get(url);
}

The expected result would be:

  • 1 successful request
  • 9 throttled requests (HTTP 429 error)

But the actual result was the opposite:

  • 9 successful requests
  • 1 throttled request (HTTP 429 error)

I repeated the process, but making 20 simultaneous request and the result was:

  • 16 successful requests
  • 4 throttled requests (HTTP 429 error)

On CloudWatch logs for this API method, I found different Log streams, each one with only few milliseconds difference.

enter image description here

If I set Rate to 0 requests per second and Burst to 0 request, the throttling works and ALL requests get throttlet. But when I set Rate and Bust to 1 it does not work as expected.

Why is that happening? I need to limit my API to only 1 request per second.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

There are two ways to apply limits on API calls:

  1. Account-level throttling
  2. API-level and stage-level throttling

When you need to apply API-level or stage-level throttling, you have to use usage plans:

A usage plan specifies who can access one or more deployed API stages and methods—and also how much and how fast they can access them

over 4 years ago · Santiago Trujillo Relatório

0

It seems AWS API Gateway throttling is not very precise for small values of rate/burst.

I imagine that there are multiple "instances" of the API Gateway running, and the values of rate and burst are "eventually consistent".

However I did not find any documentation about that.

When I made an initial request and wait 500 milliseconds before making other 99 requests, the results were "less imprecise".

Example:

axios.get(url);
setTimeout(function(){
    console.log("After 500 ms");
    for (let i=0; i<99; i++) {
        axios.get(url);
    }
}, 500);

Results:

  • Once I got 1 success and 99 throttles.
  • Other time I got 12 success and 88 throttles.
  • Other time I got 33 success and 67 throttles.

However, it's difficult to have consistent results.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda