1. Global routing: pick the best region
Requests first arrive at a global router that selects an optimal region for each request. The router uses factors like geographic location, available compute capacity, and hardware requirements to choose where to route. For example, a request from India and one from Texas will likely be routed to different regions to reduce latency and meet hardware constraints.2. Regional application layer
Once the router assigns a region, the request goes to a fleet of application servers (not a single machine). A regional load balancer distributes traffic across hundreds of application servers. These servers handle:- Authentication and authorization
- Quota and usage checks
- Retrieving conversation history and contextual data
3. Databases and caches: making reads cheap
A conventional relational database—PostgreSQL—is a core backend component. A single primary handles writes while many read replicas (dozens across regions) serve read traffic. To avoid hitting Postgres for every request, the system relies heavily on in-memory caching. If many requests need the same data, one request fetches it from Postgres and populates the cache; the others read from that cache. To prevent a “thundering herd” during a cache miss, the cache entry is locked on miss so that if 1,000 concurrent requests miss the same key, only one request goes to Postgres while the others wait for the cache to be populated.Using read replicas plus a cache-first strategy reduces cross-region latency and protects the primary database from read spikes. This pattern improves throughput and lowers costs.
4. Inference scheduling: choose the right GPU cluster
After the application servers prepare the request and fetch required data, the request moves to the AI stack. An inference scheduler balances requests across GPU clusters, taking into account:- Current load of each cluster
- Conversation context length (longer context increases compute)
- Whether portions of the model state are already warm on a particular machine

5. GPU clusters: batching, sharding, and streaming
Inside a GPU cluster, the runtime batches multiple requests so a single forward pass through the model can serve many users simultaneously. Large models are usually sharded across multiple GPUs (using model parallelism and pipeline parallelism); each GPU computes part of the workload and results are combined to produce the final output. Because requests are batched, GPU utilization is maximized while keeping latency acceptable. Token generation is streamed: the model emits tokens incrementally, and those tokens are streamed back to the client as they are produced so the response fills in progressively.6. Layered protections: rate limits and cost controls
To protect the system from traffic spikes and unusually expensive queries, ChatGPT enforces rate limits and controls at multiple layers—edge/global, regional application infrastructure, scheduling/cluster level, and within model-serving components. These layered protections prevent sudden bursts from overwhelming databases, caches, or GPU clusters.Rate limits and multi-layer controls are essential to maintain availability during traffic spikes and to prevent expensive single queries from degrading overall performance.
High-level request journey
Putting the pieces together, a ChatGPT request follows this high-level path:- Global router selects an optimal region.
- Regional load balancer forwards the request to an application server.
- Application server authenticates the user, checks quotas, and fetches or assembles required data (using caches and read replicas where possible).
- Inference scheduler assigns the prepared request to a suitable GPU cluster.
- The cluster batches requests, runs the model (possibly across multiple GPUs), and streams generated tokens back to the client.


Components at a glance
Links and references
- OpenAI
- PostgreSQL
- Kubernetes basics (operational context for many deployments)