> ## Documentation Index
> Fetch the complete documentation index at: https://docs.breakscale.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Stripe: correctness over availability

> Refusing work rather than charging twice

A simplified reconstruction of Stripe from their published posts on rate limiters, idempotency and the ledger; numbers are illustrative. Duplicate retries answer from the idempotency store, a breaker fails charges fast when the card networks brown out, webhooks redeliver onto a dead-letter shelf, and at 4x the gateway sheds excess charges at the door while dashboards throttle against their replicas. Crash the ledger: charges stop dead, dashboards keep reading, and that ordering is the design.

## What to watch

A payment is the one thing you must never do twice. Each charge carries a key, and a retry of a charge already made gets the stored answer back instead of a second charge.

Right click the card networks and inject errors. The breaker beside them opens, and charges start failing immediately instead of hanging. A payment that fails cleanly can be retried; one left in the air while a slow network times out is the one nobody can account for.

Dashboards read copies of the ledger, behind their own limit. Someone loading a big report can never make a payment wait, because the two never share a queue.

## What it is made of

| Component       | Count |
| --------------- | ----: |
| Cache           |     1 |
| Circuit breaker |     1 |
| Client          |     2 |
| Database        |     1 |
| Rate limiter    |     1 |
| Read replicas   |     1 |
| Retry queue     |     1 |
| Scheduled job   |     1 |
| Service         |     6 |
| apigateway      |     1 |
| streambroker    |     1 |
| timeseriesdb    |     1 |

## Under load

Measured by running this design through the simulator at multiples of its own offered rate of 220 requests a second. Twenty seconds of simulated time, one fixed seed, so the same numbers come out every time.

| Offered | Goodput |     p99 | Errors |
| ------: | ------: | ------: | -----: |
|     220 |     232 | 388.7ms |   1.4% |
|     330 |     309 | 505.9ms |   8.3% |
|     440 |     334 | 484.6ms |    24% |
|     550 |     400 | 482.1ms |    27% |
|     660 |     384 |   484ms |  40.5% |
|     880 |     402 | 536.5ms |  55.1% |
|    1320 |     396 | 506.3ms |  70.1% |
|    1760 |     394 | 533.6ms |  76.1% |

<Card title="Open this example" icon="play" href="https://breakscale.tech">
  Load **Stripe: correctness over availability** from the Examples menu and drag the traffic slider yourself.
</Card>
