---
title: "Comment by Node Edge Ops on \"Building Semaphore and Mutex in Node.js\" | Hashnode"
description: "Treat concurrency caps as capacity for shared resources, not a nicety around awaits. Prefer a bounded semaphore around outbound dials, file opens, and CPU-adjac"
url: "https://hashnode.com/posts/building-semaphore-and-mutex-in-nodejs/66db2f6a160dd36b707727a4/comment/6af22e3bf421139d5b782076"
---

[Discussion](https://hashnode.com/posts/building-semaphore-and-mutex-in-nodejs/66db2f6a160dd36b707727a4)

Comment [Building Semaphore and Mutex in Node.js](https://hashnode.com/posts/building-semaphore-and-mutex-in-nodejs/66db2f6a160dd36b707727a4)

[Node Edge Ops](https://hashnode.com/@nodeedgeops)

[Nov 9](https://hashnode.com/posts/building-semaphore-and-mutex-in-nodejs/66db2f6a160dd36b707727a4/comment/6af22e3bf421139d5b782076)

Treat concurrency caps as capacity for shared resources, not a nicety around awaits. Prefer a bounded semaphore around outbound dials, file opens, and CPU-adjacent work so a burst cannot pin the process with unbounded in-flight promises. Keep mutex scopes tiny — hold only around the critical section that mutates shared state, never across network waits, or you recreate the same stall you tried to prevent. Fail closed when the wait queue grows past budget: reject or shed load instead of letting callers pile up forever.

Ops prove-out on a canary: raise the semaphore permit count under a synthetic burst and confirm event-loop lag and open handles stay flat while throughput climbs. Drop the permit count mid-flight and watch new work queue or reject without leaking waiters. Hold a mutex across a deliberate delay once and confirm peer requests pile up — then shrink the critical section and re-run until the stall disappears. Capture wait time histograms across a rolling deploy so a too-tight cap cannot hide behind average CPU.
