Memory per connection
Memory per connection is the amount of RAM required to maintain one persistent WebSocket connection, including its goroutines, stacks, read and write buffers, internal connection state, and application-level bookkeeping. In this course, we estimate approximately 20 to 40 KiB per connection as a planning assumption and multiply it by the expected number of concurrent connections.
Minimal example
const connectionMemoryKiB = 32
const connections = 25000
memoryKiB := connections * connectionMemoryKiB
memoryMiB := float64(memoryKiB) / 1024
fmt.Printf("%.0f MiB\n", memoryMiB)Learn this concept
Lesson 5.14 · Capacity estimationPrerequisite conceptsGoroutines