-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance: Don't block the event loop #294
Comments
Can I take this? |
Ideas:
Other ideas? |
Sure, with pleasure. Let's just first exchange some ideas here? |
Yeah, definitely! Few questions:
|
@TheHollidayInn My thoughts:
-Which express example? I saw many messages there Remember that our main goal is to curate/summarize content, hence all the information we gathered here should be propritized and only the gist should be included in the TLDR, some of the others should be part of the "more info". What we lack here is good bibilopgraphy/posts on how the event loop works and what happen when it's blocked |
@i0natan Thanks!
As for the Express example, I see this a lot in code I work on:
Where users run code after the Express response. I'm guessing as long as they are not using synchronous actions then this is okay and doesn't block the event loop, but it seems in condtriction to Anyway, I'm not sure if it matters, but wonted to bring it up here. |
Following up. I found this paragraph from: https://nodejs.org/en/docs/guides/dont-block-the-event-loop/
So I think the example |
@TheHollidayInn Hey, thanks for pushing. My thoughts below.
Yes, similar
Yes, for example, there are other methods
Whenever you're ready, before PRing, I suggest sharing here a best practice brief:
|
Alright, finished reading through that series - it was amazing. Here is my first attempt and a very rough draft: TLDR; Avoid using syncronous and other Event Loop blocking functions. Node handles the Event Loop on a single thread rotating through multiple queues. Syncronous functions (usually ending with Sync) like Image of the Event Loop
|
Nice to see progress on this topic that I introduced in We should add notes on how to detect/monitor - Some ideas from npmjs |
@TheHollidayInn Thanks for improving, "great books are not written they are re-written" :] It will take me two days more to get to review this. @js-kyle, @VinayaSathyanarayana brought a good point, we should credit the people who suggested the origin ideas, any idea how to manage this? @VinayaSathyanarayana Absolutely need to provide example, though I would choose 2-3 (all of them are 10-30 LOC and pretty similar) |
(Message to Bot below) /remind me in 2 days |
@i0natan set a reminder for Jan 16th 2019 |
👋 @i0natan, |
@TheHollidayInn I somehow missed this, I think this is a really good draft, we should try to get this one going again |
Sounds good! PR posted: #373 |
Hello there! 👋 |
Ping as this is being worked on in a PR |
TLDR: You should make sure you never block the Event Loop. Node is fast when the work associated with each client at any given time is "small". In other words, each of your JavaScript callbacks should complete quickly, to avoid performance impacts.
Otherwise: The throughput (requests/second) of your server will suffer.
Suggested resources:
The text was updated successfully, but these errors were encountered: