Production AI
2 Questions Decide Between WebSocket and SSE

For one-way LLM streaming, SSE is often the better default than WebSocket.
WebSocket feels like the natural choice for chat, but it is often the wrong default.
In most LLM apps, the flow is pretty simple:
- the user sends one message
- the server streams one answer
- the turn ends
So this is really a long HTTP response, not a full-duplex conversation.
SSE fits that pattern better because:
- it stays on plain HTTP
- it works cleanly through proxies, firewalls and CDNs
- servers can stay stateless
- reconnection is built in
- HTTP/2 removes the old per-domain connection limit
WebSocket still has a place, but only when the client needs to talk during the stream:
- voice
- interruption mid-response
- collaborative or multi-user agent sessions
If the user only asks a question and receives a streamed answer, use SSE.
If the client needs to send data back while the stream is live, use WebSocket.
For stop-generating, a separate cancel request with the request ID is enough.
One small implementation note: browser EventSource only supports GET. If you need POST with a body, use fetch with a ReadableStream instead.
Choose the protocol based on the traffic pattern, not the product label.
Which protocol did your team choose, and what constraint decided it?
#GenAI #SoftwareArchitecture #LLMOps