# Diagnosing a higher-than-expected Upstash command bill

## Symptom

The console shows far more commands than your traffic should produce.

## Step 1: find the multiplier

Divide total commands by total requests. A healthy web app is usually
1-5 Redis commands per request. If you see 20+, something is chatty.

## Step 2: check the usual suspects

1. Await in a loop. Fetching N keys one await at a time is N HTTP
   requests. Batch with Promise.all (auto-pipelining merges them) or
   one MGET.
2. Polling. A 100ms poll loop is 864K commands a day per consumer.
   Lengthen the interval or switch queue consumers to the native
   protocol with blocking commands.
3. Rate limiting with sliding window plus analytics: 5-6 commands per
   request. Fixed window drops it to 3-4. At 1M requests a day that
difference is millions of commands a month.
4. Deny lists add 2 commands per limit call. Auto IP deny-list
   refresh costs 9 commands once a day.
5. MONITOR or DEBUG sessions left running: MONITOR streams every
   command and each observed command still counts.
6. Health checks hitting Redis every few seconds from every instance.

## Step 3: fix

Batch, lengthen polls, pick cheaper algorithms, and put a budget cap
with 70% and 90% alerts on the database so the next spike pages you
instead of billing you.

## Verify

Commands per request drops in the console graphs within the hour, and
the daily run rate projects under your budget.