Closed anthonymartin closed 11 years ago
Wait.for let's you call async functions AS IF they're Sync. It DOES NOT call them in Sync mode (it's not possible, they're async!)
Check the code, internally, the fn is called normally, with a callback, _and node's event loop keeps spinning happily_ -AKA: blazing fast performance-. It's your "fiber" or "generator" which it's paused until the async callback is called. The only performance hit is the one associated with node-fibers (very light context switch) or with ES6-generators (will depend on final specifications from ECMA)
To really measure performance, the best you can do is create some tests from part of your code, with and without wait.for. Please post them here. I'm interested in real world examples. Greetings.
Awesome, thanks for the explanation!
According to linkedin engineers in this blog post: http://engineering.linkedin.com/nodejs/blazing-fast-nodejs-10-performance-tips-linkedin-mobile, because of node's single threaded architecture, using synchronous calls in nodejs will greatly degrade the performance of an application. They say in their benchmarks, "one synchronous call caused a performance drop from thousands of requests per second to just a few dozen".
With this in mind, would one want to still want to use something like waitfor if scalability is of any concern?