ChatGPT system design: one prompt, from your phone to the GPUs and back
Follow one prompt through the edge, auth, rate limits and GPU inference, then watch the answer stream back token by token and get saved.
Send a message
You press send, and your message joins thousands of others arriving in the same second. A load balancer spreads that traffic across servers.
A firewall drops anything that looks like an attack, and the API gateway finds the message service.
This orchestrator runs four checks before any AI is involved.
First: are you signed in? Auth validates your token.
Second: have you sent too many?
A counter in Redis keeps score, so no one user can flood the GPUs.
Third: is the prompt safe to answer? Moderation screens it before it ever reaches the model.
Fourth: your chat history, read from the database, so the model remembers the thread.
Notice: not one GPU has touched your message yet.
Only now does the AI start. A gateway picks the model, builds the input, and a scheduler batches it.
The GPUs read your whole prompt in one pass, the prefill, and keep it in a KV cache.
Then decode: they write the answer one token at a time, each step reading that cache instead of starting over.
It doesn’t wait for the end. Each token comes back over one open connection, server-sent events, so you watch the answer appear while it’s still being written.
When it’s finished, the exchange is saved to the database, and copied to read replicas for the next time you open the app.
Last, a done event tells your phone the conversation is safe.
Seventeen systems, and in real life, a few seconds.