All jobs / Backend developer / Backend Languages
Backend developer interview question · 1–3 years
A Node service that normally answers in 20 ms starts timing out on every endpoint whenever one particular report is requested.
What do you suspect first?
The strongest answer
Something on that path runs synchronously — a long loop, a large JSON parse, a sync file or crypto call — and it blocks the single thread that runs your JavaScript, so every other request waits behind it
Why it works
Exactly — one thread runs your code, so a synchronous stretch stalls everyone, not only the caller.
What a good answer covers
- One thread runs your code.
- Find the synchronous stretch.
- Move CPU work off the loop.
- One slow path stalls every path.
Answers that fall short
- Close, but not the strongest: That endpoint is slow, so I would put a timeout on it and fail faster
A timeout protects that caller; it does nothing for the requests already queued behind a blocked loop. - Weak: The process ran out of threads; I would raise the thread pool size so more requests can run at once
There is a pool for some I/O, but your JavaScript runs on one thread and raising the pool does not unblock it. - Red flag: Node cannot do CPU work, so I would restart the process whenever latency rises
Restarting on latency drops in-flight requests and hides a blocking call you could find in an afternoon.
Who gets asked this
More Backend Languages questions
- def add(item, bag=[]): bag.append(item); return bag — you call add(1) then add(2). What comes back the second…
- You pass a class instance and a struct to a method and both are modified inside. What does the caller see?
- When would you choose a tuple over a list?
- What is the most common cause of a NullReferenceException in a new codebase?
- What is the difference between == and is?
- When do you use an array rather than a List<T>?
- You want a value from a dict, or a default if the key is missing, without raising. What do you use?
- You remove items from a List<T> inside a foreach over it and get an exception. Why?