Skip to content
Discussion options

You must be logged in to vote

The recommendation is correct, but the reasoning is often misunderstood. You're right that async doesn't reduce CPU time — the computation is identical. The benefit is about not blocking the Node.js event loop.

Why async matters for bcrypt specifically:

Node.js is single-threaded. bcrypt.hashSync() occupies that thread entirely for ~100ms (cost factor 10 on modern hardware). During that time, your server cannot process any other incoming requests.

bcrypt.hash() (async) offloads the work to libuv's thread pool (default: 4 threads), keeping the event loop free.

Sync: [request] → [event loop BLOCKED 100ms] → [response]
^^^^^^^^ no other requests served

Async: [request] → [thread pool] → [eve…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by recrsn
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants