Browse Source

Reduce WebSocket buffer sizes from 10MB to 64KB per connection (v0.52.12)

Previous: 10MB read + 10MB write = 20MB per connection
New: 64KB read + 64KB write = 128KB per connection

With 100 connections:
- Before: 2GB just for buffers
- After: 12.5MB for buffers

The read limit (SetReadLimit) still allows 10MB messages, but the
internal buffers don't need to be that large.

Files modified:
- app/handle-websocket.go: Reduce buffer sizes
- pkg/version/version: Bump to v0.52.12

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
main v0.52.12
woikos 4 months ago
parent
commit
a768be22e6
No known key found for this signature in database
  1. 6
      app/handle-websocket.go
  2. 2
      pkg/version/version

6
app/handle-websocket.go

@ -100,8 +100,10 @@ whitelist: @@ -100,8 +100,10 @@ whitelist:
var conn *websocket.Conn
// Configure upgrader for this connection
upgrader.ReadBufferSize = int(DefaultMaxMessageSize)
upgrader.WriteBufferSize = int(DefaultMaxMessageSize)
// Use reasonable buffer sizes (64KB) instead of max message size (10MB)
// to prevent memory exhaustion with many connections
upgrader.ReadBufferSize = 64 * 1024 // 64KB
upgrader.WriteBufferSize = 64 * 1024 // 64KB
if conn, err = upgrader.Upgrade(w, r, nil); chk.E(err) {
log.E.F("websocket accept failed from %s: %v", remote, err)

2
pkg/version/version

@ -1 +1 @@ @@ -1 +1 @@
v0.52.11
v0.52.12

Loading…
Cancel
Save