BotNetwork

Per-chat rate limits with Redis

Token buckets and fixed windows keyed by chat id.

Guide1 min readUpdated

Why it matters

Per-chat rate limits in Redis (INCR + EXPIRE or token buckets) protect your bot and the upstream platform APIs.

Practical steps

  1. Key by platform + chat/user id + action class.
  2. Prefer token buckets for bursty UX.
  3. Fail closed for expensive actions (broadcast, LLM).
  4. Return a clear retry-after to the user.
  5. Monitor key cardinality and eviction.

Watch out for

  • Global limits only — one noisy chat starves others.
  • No TTL on rate-limit keys.

Related comparisons and tools