|
| 1 | +--- |
| 2 | +title: Implementation Guidelines |
| 3 | +--- |
| 4 | +{{< type-rules production="Must use the framework standard WebSocket API with default buffer sizes. No custom batching or read-ahead optimizations." tuned="May optimize WebSocket frame handling, buffer sizes, and use custom frame parsers or batched read paths." engine="No specific rules. Ranked separately from frameworks." >}} |
| 5 | + |
| 6 | + |
| 7 | +Measures WebSocket echo throughput with pipelining. Each connection upgrades via HTTP/1.1, then sends 16 text messages back-to-back before waiting for the echoes. Each echo counts as one completed response. |
| 8 | + |
| 9 | +**Connections:** 512, 4,096, 16,384 |
| 10 | +**Pipeline:** 16 (16 messages in flight per connection — send batch, drain echoes, repeat) |
| 11 | + |
| 12 | +## Workload |
| 13 | + |
| 14 | +1. Open TCP connection to port 8080 |
| 15 | +2. Send HTTP/1.1 upgrade request to `/ws` |
| 16 | +3. After receiving `101 Switching Protocols`, switch to WebSocket framing |
| 17 | +4. Send 16 text frames containing `"hello"` back-to-back, then read 16 echo frames |
| 18 | +5. Measure messages per second |
| 19 | + |
| 20 | +## What it measures |
| 21 | + |
| 22 | +- WebSocket frame parsing efficiency under burst load |
| 23 | +- Frameworks that drain multiple frames from a single read buffer gain a major advantage |
| 24 | +- Frameworks processing one frame at a time per connection see minimal improvement over the non-pipelined echo |
| 25 | +- Write coalescing and syscall reduction on the send path |
| 26 | + |
| 27 | +## Expected upgrade request/response |
| 28 | + |
| 29 | +``` |
| 30 | +GET /ws HTTP/1.1 |
| 31 | +Host: localhost:8080 |
| 32 | +Upgrade: websocket |
| 33 | +Connection: Upgrade |
| 34 | +Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== |
| 35 | +Sec-WebSocket-Version: 13 |
| 36 | +``` |
| 37 | + |
| 38 | +``` |
| 39 | +HTTP/1.1 101 Switching Protocols |
| 40 | +Upgrade: websocket |
| 41 | +Connection: Upgrade |
| 42 | +Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= |
| 43 | +``` |
| 44 | + |
| 45 | +## Parameters |
| 46 | + |
| 47 | +| Parameter | Value | |
| 48 | +|-----------|-------| |
| 49 | +| Endpoint | `/ws` (WebSocket upgrade) | |
| 50 | +| Connections | 512, 4,096, 16,384 | |
| 51 | +| Pipeline | 16 (16 messages in flight per connection) | |
| 52 | +| Message | `"hello"` (5 bytes, text frame) | |
| 53 | +| Duration | 5s | |
| 54 | +| Runs | 3 (best taken) | |
| 55 | +| Load generator | gcannon `--ws -p 16` | |
0 commit comments