← Haider Zaman

Migrating Node.js services to Go under real traffic

When the Node service that worked fine at launch stops keeping up.

Node.js is a good way to ship fast. Most of the services in our ad stack at Advergic started in Node, including the analytics service and the bot detection platform. Then we pointed traffic from more publisher sites at them, and they started having problems: latency spikes, memory climbing until restarts, and one slow dependency backing up everything behind it.

We moved those services to Go. Here's how I approach that kind of migration, and when I'd tell you not to do it.

First, check it's really Node's fault

A rewrite is expensive. Before starting one, I profile the service and look for the cheaper fixes: an unindexed query, a missing cache, a synchronous call on the hot path, a queue consumer with no backpressure. If one of those is the real problem, fixing it in Node takes days instead of weeks.

Go makes sense when the problem is the shape of the work: lots of concurrent requests that each fan out to several stores, CPU-heavy work like hashing or scoring on every event, or strict latency budgets where garbage collection pauses and event loop blocking keep showing up in your p99.

How I run the migration

Things that bite during a Node to Go move

How I can help

Node service struggling under load?

Email haiderzamanusafxay@gmail.com with what it does and what's going wrong. I'll tell you honestly whether Go is the answer.