Menu

1 / 2

Go Channels Aren't Free. Here's the Real Cost

DEV Community·Gabriel Anhaia·7 months ago
#MmuqEpIy
#go#performance#concurrency#mutex#runtime
Reading 0:00
15s threshold

Book: The Complete Guide to Go Programming

Also by me: Thinking in Go (2-book series) — Complete Guide to Go Programming + Hexagonal Architecture in Go

My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools

Me: xgabriel.com | GitHub

A team I talked to last month was chasing a CPU spike on a

hot-path service. Twelve thousand requests per second, p99

crawling north of forty milliseconds for no obvious reason.

The code looked clean: a request counter behind a channel,

a goroutine that drained the channel and updated a metric.

"Share memory by communicating," the slogan goes. They

followed it.

The fix was three lines. They replaced the counter channel

with a sync.Mutex and a plain int64 . CPU dropped by

roughly a third. p99 came back to a flat line. The channel

was the bottleneck.

This is not a story about channels being bad.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.