One counter, shared by every server

Build a rate limiter on KiviDB: fixed windows with INCR and EXPIRE, sliding windows with sorted sets, shared by every instance of your API.

A limit only holds if every instance of your API counts against the same number. Keep the counters in KiviDB and each instance sees the same total.

Where KiviDB sits

A request → Your API (lets it through or answers 429) → KiviDB (one counter per client, per window)

Pick the window that fits

  • Fixed window INCR a key named for the caller and the minute, and expire it. Two commands, in one transaction.
  • Sliding window Add each request to a sorted set scored by its time, remove what is older than the window, and count what is left.
  • Bounded counters INCREX increments with an upper bound and an expiry in a single command.

What KiviDB Cloud adds

  • Replicas and failover On the Pro plan a replica takes over when the primary is lost, and the hostname your application uses stays the same.
  • Durability An append-only log on paid plans, snapshots on demand, and scheduled snapshots you can switch on.
  • Access control A firewall per database, closed until you open it, database users with their own permissions, and private connectivity.

Other use cases

  • Caching: Keep hot data in memory in front of a slower store.
  • Session store: Sessions that every application server can read.
  • Leaderboards: Ranked lists that update as scores change.

Protect your API with a shared counter

Create a free database and count against it from every instance.