Design Resumable Token Streaming for ChatGPT Responses Across Reconnects
Last updated: November 29, 2026
Quick Overview
Design the delivery path that streams model tokens to ChatGPT clients so that a user who loses connectivity mid-answer can reconnect, from any device, and resume the same response without regenerating it.
OpenAI
November 29, 20260
0
0 solved
Design the delivery path that streams model tokens to ChatGPT clients so that a user who loses connectivity mid-answer can reconnect, from any device, and resume the same response without regenerating it.
OpenAI streams almost every ChatGPT and API response token by token, and long reasoning answers can run for minutes while phones switch networks. Interviewers use this to see whether you can decouple generation from delivery, reason about ordering and replay, and avoid wasting expensive GPU work when a socket drops.
What the Interviewer Expects
- Separate the inference worker's lifetime from the client connection's lifetime
- Assign every token chunk a monotonically increasing offset per response and support resume-from-offset
- Choose a durable but cheap buffer for in-flight streams with a sensible TTL
- Explain how a reconnect finds the right buffer without sticky routing to one gateway
- Handle cancellation, completion and persistence of the final message to conversation storage
- Quantify buffer memory using concurrent streams and tokens per second
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How do you support a second device watching the same response live?
- What happens if the inference worker itself dies at token 800 of 2,000?
- How would you keep end-to-end time to first token under 300 ms while adding this buffering layer?
- How do you bill tokens that were generated but never delivered?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional: stream tokens over SSE or WebSocket; on disconnect the client reconnects with (response_id, last_offset) and receives everything after that offset, then continues live; users can sto...
High-Level Design
- Edge gateway terminates TLS and holds the client connection. It is stateless with respect to generation.
- Orchestrator accepts the request, picks an inference cluster, creates `response_i...