Llm Inference Serving medium
You are exposing a chat completion endpoint used by browsers and server-side SDKs, many of them behind corporate proxies. Each request sends one prompt and receives one stream of tokens, and your load balancers are stateless HTTP. A teammate proposes WebSockets 'for lower token latency.' What should you choose?
- A WebSockets, because their framing delivers each token measurably faster than an HTTP response stream can.
- B Long polling, because each poll returns a batch of tokens and avoids holding connections open on the server.
- C WebSockets, because SSE cannot resume a dropped stream and loses every token generated after a disconnect.
- D SSE over HTTP, since the stream is one-way and reuses standard HTTP infrastructure, auth, and load balancing.
Answer: D. SSE over HTTP, since the stream is one-way and reuses standard HTTP infrastructure, auth, and load balancing.
Token latency is set by decode speed, not transport framing, so **SSE** gives the same perceived speed while keeping requests stateless and proxy-friendly. Option C is wrong because SSE supports resumption via **Last-Event-ID** if the server buffers events. WebSockets are the right choice when the client must send data mid-stream, for example voice interruption or tool results, which is worth the extra cost of stateful connections.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- Your 70B-class model servers each handle about 40 concurrent chats with 4K-token contexts. Product raises the maximum context to 32K tokens, and many users start using it. What is the main capacity consequence?
- A 70B-class model (80 layers, grouped-query attention with 8 KV heads of dimension 128) is served in fp16 on one 8-GPU node with about 640 GB of total HBM. Product wants 256 concurrent sessions, each holding a full 32K-token context. What is the binding constraint, and what does it imply?
- Your server reserves a contiguous KV region sized for max_tokens = 8,192 for every request at admission, but the average sequence ends near 600 tokens. The node reports out-of-KV-memory at about 20 concurrent requests while GPU compute sits at 30%. Which change best raises concurrency without restricting legitimate long outputs?
- You must summarize 10 million documents overnight, and no user is waiting on any single result. How should you configure the serving stack compared with your interactive chat deployment?
- You serve a 7B-parameter model in fp16 (about 14 GB of weights) for a chat app. Users say single-conversation token generation is too slow, and you are choosing new GPU hardware. Which hardware spec most directly increases per-sequence decode speed?
- Your RAG workload sends 8K-token prompts and gets ~150-token answers from a 70B-class model. You plan to move prefill and decode onto separate GPU pools so long prefills stop stalling decode. What new resource must you size carefully?