# Sliding window plus multi-region rate limiting is a cost trap

## What you see

limit() calls get slow and your command bill jumps after switching to
MultiRegionRatelimit with the sliding window algorithm.

## Why

Sliding window already costs 4-5 commands per limit() call regionally.
Multi-region multiplies writes by (1 + read region count). The docs
warn explicitly: sliding window in a multi-region setup produces large
command counts and long request processing times.

## Fix

Switch the limiter to fixed window for multi-region deployments:

const ratelimit = new MultiRegionRatelimit({
  redis: [new Redis({ /* region 1 */ }), new Redis({ /* region 2 */ })],
  limiter: MultiRegionRatelimit.fixedWindow(10, "10 s"),
});

Fixed window costs 2-3 commands per call regionally, so the multiplied
cost stays manageable.

## Alternatives

- If you need sliding windows accuracy, run regional limiters and
  accept per-region limits instead of global ones.
- Use a Global Upstash Redis database as the single backend instead of
  MultiRegionRatelimit: one write fans out server side.

## Verify

Watch per-request latency on limit() drop and the command count per
request in the console fall to the fixed-window level.