DEV Community

Cover image for Basic Concepts of Node.js

Basic Concepts of Node.js

Cássio Santiago Cappellari on August 25, 2021

🔶 Introduction Imagine a web application which sends hundreds of requests per second to a server that only processes one request per tim...
Collapse
 
ahmadawais profile image
Ahmad Awais ⚡️ • Edited

Unfortunately that's a wrong diagram for the event loop. Node.js event loop is not like the JavaScript loop at all. 99% of diagrams like these are just simply wrong.

I taught this as part of my premium Node CLI Development course, but just shared that 10min video on Node.js theory, publicly for free on my YouTube Channel here.

Nodejs Event Loop

I hope it's helpful.

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for your feedback and, as a developer, I'm always looking forward to learning and improving my knowledge. I'll really appreciate suggestions about correct examples of Node.js diagrams in order to update my article, so feel free to share them!

Collapse
 
ahmadawais profile image
Ahmad Awais ⚡️ • Edited

I taught this as part of my premium Node CLI Development course, but just shared that 10min video on Node.js theory, publicly for free on my YouTube Channel here.

I hope it's helpful.

Collapse
 
olaviolacerda profile image
Olavio Lacerda

Would you have an example of a good diagram? Share with us, please!

Collapse
 
bam92 profile image
Abel Lifaefi Mbula

You read about event loop here.

Thread Thread
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for sharing, for sure I'll read about it!

Thread Thread
 
yiorgosc profile image
yiorgosc

I think both explanations are part of the bigger picture of what actually the event loop does. async tasks are assigned to the thread pool and when finished their call back functions are put in the event queue. when nodejs's execution stack is empty, the event pool takes the first cb from the event queue and puts it back in the stack for execution

Collapse
 
ahmadawais profile image
Ahmad Awais ⚡️

Just edited my comment with the explanation/video — I hope it helps.

Collapse
 
ppicom profile image
Pere Picó

I found this talk from Bryan Hughes, Microsoft the best there is to understand the Node.js event loop

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for sharing this valuable content!

Collapse
 
iamjonjackson_37 profile image
Jon Jackson

Hey Cássio, thanks for sharing this. I couldn't find anything online about Ryan Dahl originally being a PHP developer. What was your source for this? I'm intrigued!

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

You're welcome, thanks for reading it! Actually, in the process of writing this article I watched many Ryahn Dahl interviews and now I couldn't find the one that confirmed that he was a PHP developer. Sorry about that! What I can confirm is that he was a web developer in the early 2000s, years before Node.js development.

So, because I couldn't find the right source, I'll update my article here!

Collapse
 
dhirajpatra profile image
Dhiraj Patra

Nice after long years read a simple but informative article about nodejs

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for your feedback, I'm glad to read that!

Collapse
 
eshimischi profile image
eshimischi

And now there is Deno.. maybe it is still not so popular, however all issues of Node.js solved more or less with this new tech, created by the same guy who once created Node.js

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for your contribution, I heard about Deno and for sure I'll pay attention to this new technology!

Collapse
 
eshimischi profile image
eshimischi

Welcome! It has a lot of pros.. Typescript based and no more node_modules.. checked a lot of boilerplates and projects, for me it is a step forward even if there are those who will argue with me..

Collapse
 
authorantheya profile image
Antheya

Growed, sended, shutted??? Please, next time you post, use some English grammar tool...

Collapse
 
jerevick83 profile image
jerevick83

The message was passed and understood at least.

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks for your suggestion!

Collapse
 
itswillt profile image
Will T.

I just want to point out that Node is not single-threaded at all. Node being single-threaded is simply a misconception.

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for your contribution! In my studies about this technology I realize that Node.js it's a combination between single thread and multi thread platforms, and that is what makes it a great option for scalable web applications.

Collapse
 
anilsansak profile image
Yaşar Anıl Sansak

Great article! You have listed and explained so many great things about Node. However, I would also like to know the negative things about it.

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for your feedback, I'm glad to hear that! For sure every technology has pros and cons but, in my experience developing REST APIs, for me Node.js is a great tool and, at the moment, I couldn't tell you negative things about it!

Collapse
 
afozbek profile image
Abdullah Furkan Özbek

Wonderful article, thanks for sharing

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

You're welcome, thanks a lot for your feedback!

Collapse
 
aacraf profile image
acraf

Really helpful. Thank you!

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for your feedback, I'm glad that this article was helpful to you!

Collapse
 
margo_hdb profile image
Margo McCabe

Great post, we love NodeJS!

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for your feedback!

Collapse
 
brunotdantas profile image
Bruno Dantas

To whom this may interest, here (youtu.be/ztspvPYybIY) you can find Ryan Dahl: Original Node.js presentation explaining about Node concept and why it needs to be the way it is

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks for share such a valuable content!

Collapse
 
samritbk profile image
Beraki Befekadu

Great article.

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot!

Collapse
 
chukwuemekaigbokwe profile image
Chukwuemeka Igbokwe

Nice one

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks!

Collapse
 
olaviolacerda profile image
Olavio Lacerda

Awesome article! Keep it on! 👊

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks for your feedback and support! 👊

Collapse
 
silasalvesjunior profile image
Silas Alves Junior

Pretty good article!

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for your feedback!

Collapse
 
tanth1993 profile image
tanth1993

thanks man. now I know more about Node.js

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

You're welcome, I'm glad that this article helped you!

Collapse
 
nellygakuru profile image
Nelly Gakuru

Thank you!

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

You're welcome, thanks for reading it!

Collapse
 
gilmaragit profile image
Gilmara

Nice Cássio!

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks, Gilmara! 💙

Collapse
 
iliyas503 profile image
iliyas503

Thanks for sharing awesome info Cassio Cappellari. Keep doing and will love to read this kind of articles.

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for your feedback and for your words, I'm really glad to read that!

Collapse
 
tatianafischer profile image
Tatiana Fischer

Muito bom!!

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thank you! 💙

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks for your alert, but I believe that this Spam has already been deleted!

Collapse
 
mojtaba1996cs profile image
mojtaba1996php

Thanks for the useful article

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot, I'm glad to read that!

Collapse
 
saqibjamil7866 profile image
Saqib Jamil • Edited

Node js can be blocked, if we calculate complex calculations on main thread. Can you post another article about "how to avoid this and more about child threads".

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

Thanks a lot for your contribution and suggestions!

Collapse
 
hadderakk profile image
hadderakk

Grazie, Cássio, for explaining these features.

Collapse
 
cassiocappellari profile image
Cássio Santiago Cappellari

You're welcome, I hope that this article has helped you!