Commit Graph

9 Commits

Author SHA1 Message Date
Colin a4f41768ba
Optimize WebSocket implementation for millions of connections
- Implement sharded client storage (256 shards by default) to eliminate mutex contention
- Replace slice-based storage with map structure for O(1) token lookup
- Increase WebSocket buffer sizes (8192 bytes) and channel buffers (10 messages)
- Optimize Notify method with per-shard locking
- Add configuration options for shard count and buffer sizes
- Add comprehensive benchmarking setup with docker-compose
- Include k6 load testing scripts for WebSocket performance testing
- All existing tests pass with new sharded implementation
2025-11-20 14:43:33 -05:00
Jannis Mattheis 3454dcd602 Use golangci-lint 2020-11-01 10:47:02 +01:00
Jannis Mattheis 7b90b8a8f5 Use v2 in package path 2020-05-08 10:43:17 +02:00
Jannis Mattheis 0a7a5cd619 Add logging to websocket errors 2019-11-28 21:39:47 +01:00
eternal-flame-AD de09aae987 add extras to message model 2019-02-02 13:06:30 +01:00
Jannis Mattheis 79e1dc9c9a Prevent deadlock on stream.Close()
GR = goroutine
[GR#1] http server gets closed
[GR#2] client.NotifyClose() will be executed
[GR#2] client.once.Do will be executed (lock's client.once.m)
[GR#1] stream.Close will be executed (lock's stream.lock)
[GR#1] client.Close will be executed (waits for client.once.m)
[GR#2] stream.remove will be executed (waits for stream.lock)

GR#1 holds lock stream.lock and waits for client.once.m
GR#2 holds lock client.once.m and waits for stream.lock

We prevent the deadlock with releasing the client.once.m lock earlier.
2018-11-22 20:59:29 +01:00
Jannis Mattheis 80eec6ae3a Remove monkey dependency 2018-11-06 21:38:15 +01:00
Jannis Mattheis 6954fb5adf Close web socket connection on delete client 2018-04-02 12:35:16 +02:00
Jannis Mattheis 01c6800ae8 Move stream to api 2018-03-25 19:33:29 +02:00