Bugpit

Lessons › Real apps

UPI: 25 billion payments a month

In October 2026 UPI handled 25.47 billion payments, close to 10,000 every second on average and far more on a festival evening. You're running one twenty-fifth of an evening peak: 800 payments a second, plus 3,200 balance and status checks, 4,000 req/s in all. Every payment waits while two banks answer, and one database holds every rupee.

Play this level

Part of Bugpit Pro. It runs in your browser: build the design, press Run, and watch what breaks.

The lesson

A UPI payment crosses three systems. Your app sends it to the switch in the middle, run by NPCI. The switch asks the payer's bank to take the money and the payee's bank to give it. Two banks you don't run, and either one can be slow.

So don't keep the person waiting on both banks. Record the payment with its unique transaction ID, put it in a queue, and let workers talk to the banks. If a bank doesn't answer in time, NPCI's rules say: check the transaction's status, up to three times, then reverse it. Never just send it again.

That transaction ID is what makes retries safe. A worker that crashes halfway retries with the same ID, and the bank sees a payment it has already done, not a new one. Without it, a timeout becomes a double charge.

The ledger is where money lives, so it gets the strictest settings in the game. Replicas wait for every write, so a balance is never behind. Three machines, so only a majority can be the primary. And backups, because a bad write reaches every copy in seconds.

Last, the message saying you've been paid. It goes out from the workers after the money moves, never before.

What you have to achieve

4,000 requests a second at the busiest hour, 20% of them writes.

What you learn

Notice what made this safe, not fast: a queue, IDs, replicas that wait, a third machine and backups. UPI's real scale comes from spreading this work across hundreds of banks and apps, each holding its own ledger. The switch only routes and keeps score.

The real numbers behind it

Check yourself

A bank doesn't answer a UPI payment in time. What should happen next?

Show the answer

Check the transaction's status, then reverse it if it never completed. Sending it again could charge twice. NPCI's rules say check the status, up to three times, then reverse.

What makes it safe for a worker to retry a payment after it crashes?

Show the answer

The payment's unique transaction ID, so the bank recognises one it has already done. With the same ID, a retry is the same payment, not a new one. That's idempotency.

Try it yourself

More in Real apps

← Hotstar: 25 million watching Stripe: the order that never shipped →