# Stripe Payment Architecture

How a payment travels through Stripe's system, from the API door and per\-business request limits to bank approval, duplicate\-proof receipts and sharded records\.

By Numa

Topic: Computing, AI &amp; Electronics

[Open the interactive Jig](https://ask.jig.com/j/u8Zm53hL5ydY)

## Transcript

### 1. A payment machine, opened up

This model opens up the system behind Stripe like an anatomy model\. Each glowing card is one payment request\. Watch them race around the ring, through every layer, in a fraction of a second\.

Stripe handles more than 500 million API requests every day\.

### 2. The front door: the API

A payment starts as a short message from a shop's checkout to Stripe's API\. An API is a door that programs use to talk to each other\. Millions of businesses knock on this same door\.

On Black Friday 2023, the API peaked at 27,395 requests in one second\.

### 3. Ticket buckets keep it fair

Every business gets a bucket of tickets that slowly refills\. Each request spends one ticket\. If a runaway program empties its bucket, its extra requests must wait, so nobody crowds out everyone else\.

This is called rate limiting\. Try a burst and watch the gate\.

### 4. When it's busy, payments go first

If the whole system gets crowded, Stripe keeps a lane open for the most important work, like charging a card\. Less urgent requests are politely asked to try again in a moment\.

In Stripe's own example, about a fifth of capacity is held back for critical requests\.

### 5. The receipt number

Networks sometimes lose a reply, so the shop sends the same request again\. Each request carries a unique key, like a receipt number\. Stripe spots the key, hands back the saved answer, and the customer pays only once\.

This safe\-retry trick is called idempotency\.

### 6. Asking the bank

Next, Stripe passes the payment to the card network and the customer's bank\. They check the card and answer yes or no\. The answer races back while the shopper is still at the checkout\.

### 7. Thousands of small filing cabinets

Every payment is written down safely\. Instead of one giant database, Stripe spreads its records over more than 2,000 smaller pieces called shards\. A routing desk, the proxy, knows which shard holds each record\.

Together they answer about 5 million database questions per second\.

### 8. Splitting a shard without stopping

When a shard grows too full, Stripe copies its records into a new shard while payments keep flowing\. Then the routing desk switches over so quickly that nobody notices\.

The switch takes milliseconds, and never more than 2 seconds\.

### 9. Many small parts, always on

Finally, a message called a webhook rings back to the shop with the result\. Because the work is spread over many small parts that can grow and be replaced, Stripe has stayed up 99\.999% of the time\.

That is less than half a minute of downtime a month\.
