DEV Community

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

Collapse
 
imichaelowolabi profile image
Michael Owolabi

Thank you @romeerez for your concern for good content which I agree with you that we should hold ouselves to a better standard. However, your opening statement just isn't true because the article has since been updated before your comment.

The article isn't describing n+1 problem as that isn't peculiar to Node.js.

Anyway, thank you for your concern.

Collapse
 
romeerez profile image
Roman K

Sorry! My bad, really, I read it before and yesterday just very briefly looked through and I see the same problem, I see section about event loop so I thought it wasn't changed

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