Repository navigation
v2.4.2
Tako 2.4.2 fixes two WebSocket problems that running Tako in HttpArena brought to light: each connection's read buffer was zero-filled before every socket read, and an upgraded connection stopped counting toward max_connections and the per-thread balancer as soon as the upgrade completed.
No code changes are needed. All eight workspace crates are versioned together at 2.4.2 and require Rust 1.95 or newer.
Performance
TakoWsreads into a 4 KiB buffer by default instead of tungstenite's 128 KiB. tungstenite zero-fills the spare capacity of its read buffer before every socket read, so each echoed message paid for up to two 128 KiB memsets, and each connection held about 140 KiB. With thousands of connections those memsets no longer fit in cache, and throughput stalled on memory bandwidth.TakoWs::read_buffer_sizeraises the buffer for large messages.GraphQLSubscriptionuses the same 4 KiB buffer.
Echoes per second, the median of three 5-second runs in a Docker Linux VM (arm64) on an Apple M4 Max, with serve_per_thread on 4 vCPUs and the load generator on 4 more, each connection echoing a 5-byte text message one at a time:
| Workload | 2.4.1 | 2.4.2 |
|---|---|---|
| Echo, 512 connections | 330,572 | 459,906 |
| Echo, 4,096 connections | 312,075 | 447,724 |
| Echo, 16,384 connections | 254,425 | 394,795 |
| Echo, a new connection every 10 messages, 512 connections | 166,483 | 286,834 |
At 16,384 connections the server's resident memory drops from 2.2 GiB to 187 MiB.
Fixed
- An upgraded connection, such as a WebSocket, keeps its
max_connectionspermit and itsserve_per_threadbalancer slot until its socket closes. Both used to be released when the HTTP/1 connection handed its socket to the upgrade, so open WebSockets did not count againstmax_connections, and the per-thread balancer placed new connections as if they were not there. This covers the TCP, TLS, Unix socket, vsock, and PROXY protocol listeners and the per-thread server; the Compio listeners are unchanged. If you setmax_connections, size it for your open WebSockets too.
Full diff: v2.4.1...v2.4.2