# Diagnosing large-value failures on Upstash Redis

## Symptom

SETs of big objects fail with 400s, or succeed but burn through the
monthly bandwidth quota fast.

## Step 1: measure the real wire size

The limits are 10MB per request and 100MB per record, but JSON
serialization plus base64 encoding inflates values. A 7MB object can
cross 10MB on the wire. Measure the serialized bytes, not the
in-memory object.

## Step 2: decide the fix

- Under the limit but heavy: compress. JSON and text compress 5-10x
  with gzip. Compress client side, store bytes, decompress on read.
- Over 10MB per write: chunk across keys (doc:1, doc:2, ...) and
  reassemble on read, or pipeline the chunks.
- Over 100MB or rarely read: store the blob in object storage and
  keep the URL plus metadata in Redis. Redis stays the index.
- Session-sized data (KBs): no action needed. This skill is for the
  outliers.

## Step 3: watch bandwidth

The free tier allows 10GB a month. A 5MB value read 2,000 times is
10GB. Large values multiply bandwidth fast; cache them at the edge
or in the client.

## Verify

The write returns OK, GET returns byte-identical content, and the
bandwidth graph in the console grows at the expected rate.