
How I Optimised a Node.js API from 2 seconds to 80ms
A production debugging story with real code, real numbers, and every mistake I made along the way. It started with a Slack message on a Tuesday afternoon: “Hey, the dashboard is loading really slowly. Like, really slowly.” Our internal analytics API was taking anywhere between 1.8s and 2.4s to respond. Users had complained. The tech lead had noticed. It was time to fix it. I spent two days profiling, debugging, and fixing five separate issues. This article walks through each one — with real code, real numbers, and honest mistakes. “Performance problems are almost never where you think they are. Profile first. Always.” Step 0: Baseline measurement Before touching any code, I needed to know where time was actually being spent. I started with simple timing: async function timedRoute(label, fn) { const start = performance.now(); const result = await fn(); const ms = (performance.now() - start).toFixed(2); console.log(`[PERF] ${label}: ${ms}ms`); return result; } // Usage const user = await
Continue reading on Dev.to JavaScript
Opens in a new tab



