Video in progress
You want to release a new version of the WebSocket server as a canary. How does that differ from a canary of an HTTP service?
Splitting traffic by percentage affects only new connections, while old ones stay on the old version for hours. So the canary fills up slowly, and a rollback means cutting connections. The protocol has to work in both directions, and metrics have to be split by version.
📖 Answer
With HTTP you say "5% of traffic to the new version" and within a minute 5% of requests are going there. With WebSocket, 5% means 5 percent of new handshakes. At night few people connect, so only a few hundred connections build up on the canary pod over several hours. Data for making a decision accumulates slowly too.
What I do:
Fill the canary on purpose. I cut a small share (say 2 to 3%) from the old pods with jitter. The clients reconnect and some land on the canary. This is similar to a normal deploy drain, just on a small scale.
The cost of rollback. If the canary turns out bad, removing it means cutting its connections. A rollback is also a reconnect wave, so I keep the canary small: when it goes down, the remaining pods can easily absorb its clients.
Protocol compatibility. One tab of a user may be connected to the old server and another to the new one. And a single client may "jump" between versions when it reconnects. So the new server must understand the old client, and the old server the new client. During the canary I send a new message type only "if the client asks for it".
Metrics per version. Open connections, the distribution of close codes, disconnect rate, message latency, memory: all with a version tag. If the share of 1011 or 1006 goes up on the canary, you won't see it inside the average numbers.
Wait long enough. Some problems (a memory leak, half-open connections piling up) only show up after the connections have lived for several hours. Where 15 minutes is enough for an HTTP canary, for WebSocket I wait at least several hours, sometimes a day.
For routing I sometimes also split by cookie or header: always send internal staff to the canary. They notice a problem first and report it.
Sign up to mark studied questions and save your progress.