Rate control
What is rate-control?
O controle de taxa é uma técnica frequentemente utilizada nas APIs para limitar o número de solicitações que um usuário pode fazer a um endpoint em um determinado período de tempo. Esse limite pode ser definido por minuto, hora, dia ou outro intervalo de tempo, dependendo da política do serviço. O objetivo é proteger a API de sobrecarga, garantir a disponibilidade e a confiabilidade do serviço para todos os usuários e evitar o uso abusivo ou não intencional que possa prejudicar a infraestrutura. Para consultar o rate limit de um endpoint específico, entre em contato com o nosso Suporte.
Situations in which Rate Control may appear in Celcoin
- Heavy Usage: When a client makes many requests in a short period of time, exceeding the allowed limit.
- Distributed Workload: In scenarios where multiple instances or services make requests on behalf of the same user or system, accumulating the total requests.
- Inadequate Automation: Scripts that perform automated tasks without proper control of request frequency can easily exceed limits.
- Development and Testing: During the development and testing phase, it is common for developers to make many requests to test features, which can lead to rate control limits.
Status Code HTTP 429: Too Many Requests
When a client exceeds the limit of requests allowed by the rate control policy, Celcoin will respond with HTTP status code 429, indicating "Too Many Requests". This status code is a clear signal that the client should wait a while before trying to make new requests.
In our API documentation, we will usually include comments about any limitations on the number of requests per minute, however, this setting can be modified dynamically to reflect specific needs.
Recommendations for Customers
- Observing Response Headers: Many of our Endpoints include response headers that report the current status of the rate limit, such as the number of requests remaining and the amount of time to wait before the limit is reset.
- Implement Retry Strategies: Clients should implement retry logic with exponential backoff, waiting longer between each successive request attempt, to avoid new backlogs.
- Optimize Requests: Evaluate the need for each request and optimize the frequency and volume of API calls to stay within established limits.
- Monitoring and Alerts: Implement monitoring of requests to receive alerts when they are close to reaching limits, allowing proactive adjustments in usage.