Bugpit

Lessons › Real apps

ChatGPT: 2.5 billion prompts a day

OpenAI says ChatGPT gets 2.5 billion prompts a day, about 29,000 a second. You're running one hundredth of that: 20,000 req/s, of which 300 a second are prompts for the model. The rest is people opening their chats. One database answers all of it, and your model quota allows 17 calls a second.

Play this level

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

The lesson

An AI app is two systems. One is the model: each answer takes seconds, costs real money and is limited by how many GPUs your provider gives you. You can't add servers to fix that. You raise the quota, and you stream the answer so people see words at once.

The other is an ordinary web app: accounts, settings and the rest of the product's data. OpenAI wrote that PostgreSQL holds this with one primary taking every write and nearly 50 read replicas answering reads. It's read heavy, so it needs copies. OpenAI adds that workloads which write a lot and split cleanly were moved to a sharded database instead.

A cache answers most reads before they reach a database. OpenAI describes the danger you met earlier: when many cached answers miss at once, the flood lands on PostgreSQL. Their fix is the same: one request refills a key while the others wait.

Every app server holds database connections, and thousands of servers can use them all up. OpenAI puts PgBouncer, a connection pooler, in front, so many servers share a few connections.

Before the model answers, the app looks up what it should know: your saved memories and the files you uploaded. Those are found by meaning, not by keyword, which is a vector database's job. This step is our own addition, to show how such apps usually work.

What you have to achieve

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

What you learn

Look at the bill: the model's tokens cost far more than every machine you run. That's why AI products cache answers, use smaller models for easy questions and limit free use. And notice how plain the rest is: one primary, replicas, a cache and a pooler sit behind a product with 800 million users.

The real numbers behind it

Check yourself

You can't add GPUs to your provider. How do you make answers feel fast?

Show the answer

Stream the answer as it's written. People see words at once. To serve more prompts you raise the quota, not your server count.

What does a connection pooler like PgBouncer do?

Show the answer

Lets many app servers share a few database connections. Thousands of servers would use up the database's connections. A pooler shares a small number between them.

Try it yourself

More in Real apps

← Instagram: 3 billion people GTA VI: launch night →