Sobes.tech
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:

  1. Centralized limiter — a service or component that stores the global state of limits and distributes them among local filters.

  2. Hierarchy of limits:

    • Global limit (16,000) — common for all filters.
    • Local limits — subsets of the global limit, assigned to each filter.
  3. 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.
  4. 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).
  5. 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.

There is a local limit for a specific filter and a… - sobes.tech