Architect for Scale - My Learnings in Node.js (A case study)
summary
Cluster shows 15 nodes and one process restarts every 20 minutes due to a memory leak traced with flame graphs and heap dumps (heap dump needs ~2x memory so not viable in production). Root causes include a long‑lived object in a short request scope and an off‑by‑one ++ bug. Logging via Winston slow adds ~400 ms (328 ms spent sending logs); writing to stdout and piping works better. Authentication uses MD5 and predictable non‑expiring tokens; fix is random tokens plus an HMAC keyed by the stored password, and use bcrypt/argon2 for hashing.
AI-written summary · about
chapters (18)
- 0:00musings of
- 1:27can write bug free code
- 5:19Who can debug this?
- 5:39There is coredump
- 6:12Node debug?
- 9:22Monitor? How?
- 10:40Re-start the process before it locks you out
- 12:34Response Latency
- 13:01Winston, anyone?
- 14:13Data
- 14:24Why it's an overkill.
- 15:05Pipe it to another process
- 15:44What about debugging? Logs FTW!
- 16:56Introducing Consul
- 17:26Reactive Config
- 18:57legacy system had insecure auth code
- 20:27Non-volatile tokens
- 20:41HMAC a random string with the user's current password
related talks
25mMy node.js process is on fire
38mWelcome to Mordor! Hunting Performance Issues in Node.js.
25mNode js applications diagnostics under the hood
40mDeploying node.js at scale
01h 04mNode.js performance analytics and best practices
25mTracing Node. The Open Source Edition.
17mRunning Node.js in Production
57mTroubleshooting Node.js Applications Under the Hood
