Senior
There is a local limit for a specific filter and a global HH limit of 16,000 — how to architect this?
sobes.tech AI
Answer from AI
For an architecture with a local limit per specific filter and a global limit of 16,000 requests (for example, on HH), it is important to ensure correct and efficient quota distribution.
Main approaches:
-
Centralized limiter — a service or component that stores the global state of limits and distributes them among local filters.
-
Hierarchy of limits:
- Global limit (16,000) — common for all filters.
- Local limits — subsets of the global limit, assigned to each filter.
-
Implementation:
- When a request with a specific filter is made, the local limit is checked first.
- If the local limit is not exhausted, the global limit is checked.
- If both limits allow, the request is executed, and counters are decremented.
-
Technical details:
- Use atomic operations or distributed locks for correct counter updates.
- Store counters in a fast storage (e.g., Redis with Lua scripts for atomicity).
- Update counters considering time windows (e.g., per minute/hour).
-
Monitoring and alerts:
- Monitor the state of limits.
- Automatically redistribute local limits if necessary.
Thus, the architecture should ensure consistency and efficiency in limit control, minimizing delays and the risk of quota exceedance.