Node.js / Memory Interview Questions 2026
34 Node.js / Memory interview questions from Amazon, Razorpay, TCS, Infosys, General, Stripe and more. Real questions from Technical, System Design, and HR rounds.
All Node.js / Memory Questions
Explain the Node.js event loop phases in order. A setTimeout(fn, 0) and setImmediate(fn) are both queued. Which runs first and why? What if they're inside an I/O callback?
Your Node.js API uses async/await throughout. A developer reports that errors thrown in async route handlers are causing the process to crash with 'UnhandledPromiseRejectionWarning'. What's the architectural fix?
You're building a WebSocket server in Node.js that needs to broadcast messages to 50,000 concurrent connections. A naive broadcast loops through all 50,000 and calls socket.send(). What's wrong with this and how do you fix it?
A Node.js service crashes every night at 2 AM with 'FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory'. There's a cron job that runs at 1:55 AM. Explain the likely cause and your fix.
Design a rate limiter in Node.js that allows 100 requests per user per minute. It must work across multiple Node.js instances without a central Redis lock causing a bottleneck.
Your Node.js app has a middleware that adds request logging. In production, every slow request shows the same log message appearing 3 times. Why might this happen?
You need to process 100,000 CSV rows in Node.js without blocking the event loop and without running out of memory. The file is 2GB. How do you implement this?
Your Express.js API endpoint returns data in 80ms locally but 800ms in production. Both use the same database. What are the likely causes and how do you systematically investigate?
Explain graceful shutdown in a Node.js service. What happens to in-flight requests when you kill the process without it?
A Node.js microservice processes background jobs from a Redis queue. Under load, jobs fail and retry endlessly, creating a death loop that blocks the queue. How do you implement a proper retry strategy with dead letter handling?
Your Node.js app needs to tail a large log file (100GB, growing) and stream new lines to connected clients via WebSocket. How do you implement this efficiently?
Your Node.js API has memory usage growing from 100MB to 800MB over 24 hours with stable traffic. How do you find the leak?
Your Node.js API handles 500 requests/second in staging. In production at 2000 req/sec, memory climbs to 8GB and the process crashes after 20 minutes. How do you diagnose and fix this?
What is the N-API and why is it important for Node.js native addons? When would you write a native addon?
Your Node.js app uses the 'cluster' module with 8 workers. A user's session is stored in memory. Requests from the same user hit different workers randomly. What breaks and how do you fix it?
Design a Node.js service that must process exactly one event per user per day (deduplication). Events arrive out of order and can have duplicates. You have Redis available.
Your Express API has a middleware that measures response time. You notice async route handlers are reporting incorrect times (too short). Why?
Explain the difference between process.nextTick() and Promise.then() in the event loop. Which executes first?
You're building a Node.js API that needs to process uploaded images: resize to 3 formats, upload to S3, and update database. How do you design this for high throughput?
Your Node.js service uses Express and you want to implement request tracing across microservices. Each log line should show the same trace ID for the same request, even across async operations.
Explain how Node.js handles CPU-intensive tasks without worker threads. What happens to the event loop and all pending HTTP requests while a heavy computation runs?
Implement a JavaScript function that throttles another function: no matter how many times it's called, it executes at most once per N milliseconds.
Write a function to deep clone a JavaScript object without using JSON.parse/JSON.stringify. Handle: Date, RegExp, undefined, circular references.
Your Express app serves API and static files. Under load, static file serving consumes most of CPU. How do you fix this?
Explain how Node.js DNS resolution can unexpectedly block your service.
What are Worker Threads in Node.js and how do they differ from child_process.fork()?
Design a webhook delivery system that must guarantee at-least-once delivery to customer endpoints, with retries and backoff, without letting one slow customer endpoint block delivery to others.
Design a Node.js service that handles file uploads up to 500MB. Multiple instances run in containers. Where should uploaded files go?
What is Node.js's unhandledRejection event? How does it behave differently in Node 15+ vs earlier versions?
A developer has written res.send(eval(req.body.expression)) in your Express app. What are all the problems?
Your Node.js service sends 10K emails per hour. Email provider rate-limits at 100/second. How do you implement this without losing emails?
Your Node.js API loses precision on large numbers (e.g., 9007199254740993 becomes 9007199254740992). What's happening?
What is the difference between require() and ES module import in Node.js? What problems arise when mixing them?
Your service processes payments. During load testing at 5x normal traffic, you notice 0.01% of transactions are charged twice. At scale that's 1000 users per day. How do you find and fix this?
Practice these questions with AI feedback
Get instant grading on your answers, identify your weak areas, and generate a personalised 14-day study plan — all free.
Build my study plan →