cd /news/ai-infrastructure/zero-copy-go-why-io-copy-is-lying-to… · home topics ai-infrastructure article
[ARTICLE · art-67612] src=blog.devgenius.io ↗ pub= topic=ai-infrastructure verified=true sentiment=↓ negative

Zero-Copy Go: Why io.Copy Is Lying to You (sendfile/splice)

A developer discovered that an inference gateway's p99 latency spike was caused by unnecessary data copying in a logging middleware wrapper, not the AI model itself. Every response body was being copied from kernel space to userspace and back via io.Copy, turning the gateway into a slow photocopier. The author warns that this hidden overhead costs real throughput and money for high-traffic services like AI inference, file downloads, and video streaming.

read1 min views1 publishedJul 21, 2026
Zero-Copy Go: Why io.Copy Is Lying to You (sendfile/splice)
Image: Blog (auto-discovered)

Member-only story

Is Lying to You (sendfile/splice) Your HTTP middleware is probably copying every byte your AI gateway serves. Here’s the throughput you’re leaving on the table — measured, not guessed.

I run an inference gateway in front of our model servers. Last month we had a p99 latency spike during a traffic burst — requests that normally returned fast were stalling, and the CPU on the gateway boxes were pegged while the GPUs sat idle.

My first instinct, like an idiot, was to blame the model. “The 70B is slow under load,” I told my team. We spent two days tuning batch sizes and KV-cache before I finally looked at the gateway itself.

The model wasn’t the problem. The bytes were.

Every response body — multi-megabyte tensors, streamed tokens, the works — was being copied from kernel space into a userspace buffer and back out again, because of a logging middleware wrapper I’d written three months earlier and never thought about again. The gateway was a very expensive, very slow photocopier.

This is the io.Copy

lie. And if you serve any kind of high-throughput traffic — AI inference, file downloads, video — it's costing you real money.

── more in #ai-infrastructure 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/zero-copy-go-why-io-…] indexed:0 read:1min 2026-07-21 ·