ResendDerich Pacheco, Fabio Kubo, Bu Kinoshita, and Felipe VolponeProblem & solution
Migrating our Email API to Go
Summary
Resend migrated its email API from a Node.js service to Go over seven weeks and roughly 140 pull requests. The existing Node service suffered from failure modes where CPU-heavy request parsing and serialization blocked the event loop during bursts, and S3 timeouts surfaced as customer-facing errors. The new Go service was built to match the old API’s behavior exactly, using a test harness that compared responses, errors, database state, S3 objects, idempotency, and rate limits between the two implementations. During a 50% rollout, Go showed roughly half the median latency and about one-seventh the memory usage per task compared to Node, with 62% less CPU per request. The team also had to tune capacity, timeouts, and connection pools during the rollout, as lower average resource consumption did not predict burst requirements.
Context
The existing Node.js email API had failure modes: during bursts of large requests, CPU-heavy parsing and serialization blocked the event loop, making the whole task unresponsive. S3 timeouts also surfaced as customer-facing 408 and 524 errors. The team needed more predictable behavior under load, lower resource usage, and better control over operation timeouts.
Approach / What changed
The team built a new Go service over seven weeks, matching the old API’s behavior using a test harness that sent the same requests to both Node and Go and compared responses, errors, database rows, S3 objects, idempotency, and rate limits. They also ported the specific HTML-to-text conversion behavior to match exactly. The rollout was gradual, with capacity tuning, per-request S3 timeouts, and Redis connection pool adjustments.
Takeaways
The Go service used about 62% less CPU per request and showed roughly half the median latency and one-seventh the memory per task compared to the Node service during a 50% rollout.
To ensure backward compatibility, the team built a test harness that compared not just HTTP responses but also database state, S3 objects, idempotency behavior, and rate limits between the old and new implementations.
Lower average resource consumption did not predict burst capacity; the team had to double task sizes twice during the rollout and tune timeouts and connection pools based on production evidence.
FAQ
Why did you migrate from Node to Go?
The Node service had failure modes where CPU-heavy request parsing and serialization blocked the event loop during bursts, and S3 timeouts caused customer-facing errors. The migration aimed for more predictable behavior under load, lower resource usage, and better timeout control.
How did you ensure the new API behaved identically to the old one?
They built a test harness that sent the same requests to both Node and Go and compared responses, errors, database rows, S3 objects, idempotency, and rate limits. They also ported the specific HTML-to-text conversion behavior to match exactly.
What performance improvements did you see?
During a 50% rollout, Go showed roughly half the median latency (58 ms to 31 ms), about one-seventh the memory per task (1.3 GB to 180 MB), and 62% less CPU per request compared to Node.
Source and freshness
- Source
- resend.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.