-
Notifications
You must be signed in to change notification settings - Fork 284
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
Node.js - Event loop (handshake and requests ) #1464
Comments
for any transactions including networking, the operations that involve JS object processing is always performed by the main thread. Because Node.js leverages V8 for object management (among other things) that assumes single thread access to the object heap, this work cannot be transferred to another thread. What gets transferred to the thread-pool is the intermediary work that operates with data in native structures (C, C++). Example: HTTP protocol parsing (networking), disc I/O (file system). Hope this helps. |
But that handshake don't happen inside the main thread?? only the accept of connection? if the handshake happens in the main thread it will create delay so it should happen inside the thread pool like the HTTP protocol parsing ?? i'm quite confused about this part |
when you say handshake, do you mean the TCP handshake? If so, yes, that happens at the main thread (but at the tcp driver + kernel combination so very low overhead) At HTTP level, there is no handshake if I understand correctly, only parsing of the protocol text. That happens in the worker thread as I mentioned earlier. |
Hi gireeshpunathil I mean the TLS handshake when we are using Node.js as Https server. Node use OpenSSL after accepting the incomming client |
apologies for late response. ok, all TLS handshake happen in the main thread. There were discussions on offloading these to helper threads, but as of now, main thread itself. |
Thank you for your response and confirmation regarding the TLS handshake . Can you please point me to those discussions where to find them ? |
nodejs/node#8436 is one I remember. It may have links to other related discussions too. |
closing as answered |
Hi!
I hope someone can confirm whether it's correct understood or not.
Node.js main networking is made inside a single thread ( event loop ), but handshake and requests is sent as task to the thread pool?
So if we create Https server in Node.js the handling of incoming connections is inside a single thread, but the handshake and process of requests is handleded by the thread pool?
or is it only the requests that is sent to the thread pool, but the handshake was already taken care of inside the single thread?
Can you please help me to confirm which is correct flow?
The text was updated successfully, but these errors were encountered: