DEV Community

Discussion on: This is why your Node.js application is slow

Collapse
 
romeerez profile image
Roman K

As for N+1, it's the way how you're loading nextOfKin with Promise.all, it's not a proper solution for a problem.

In the example you're using locally defined data and setTimeout to simulate delay, in real world it will most likely be a database or API call.

In case of API call, Promise.all would be ok only if you have no other choice, and in case of database call this Promise.all will consume whole connection pool and block other users from accessing database, Necmettin Begiter and Tobias Nickel mentioned this in comments.

Like, if you awaiting 100 promises, and have just 10 available connections, it won't be fast and other users won't be able to make a query in the meantime.

So I was concerned that new comers may take this article as a teaching material and will go and implement it this way on real projects. But since you're editing it and taking care of it - that's good, wish you success