How Node.js Works | Mosh

Programming with Mosh · Beginner ·🛠️ AI Tools & Apps ·8y ago

Key Takeaways

This video explains the single-threaded, non-blocking I/O model in Node.js, comparing it to blocking or synchronous architecture used in frameworks like ASP.NET, and demonstrates how to install Node and build a first Node application

Full Transcript

[Music] so earlier I mentioned that note applications are highly scalable and this is because of the non-blocking or asynchronous nature of note what do you mean by asynchronous let me give you a metaphor imagine you go to a restaurant the waiter comes to your table takes your order and gives it to the kitchen then they move on to serve another table while the chef is preparing your meal so the same person can serve many different tables they don't have to wait for the chef to cook one meal before they serve another table this is what we call non-blocking or asynchronous architecture and this is how node applications work the waiter is like a thread allocated to handle a request so a single thread is used to handle multiple requests in contrast to non-blocking or asynchronous architecture we have blocking or synchronous architecture let's see how that works so back to our restaurant example imagine you go to another restaurant and in this restaurant a waiter is allocated to you they take your order and give it to the kitchen now they are sitting in the kitchen waiting for the chef to prepare your meal at this time they are not doing anything else they're just waiting they're not going to take an order from another table until your meal is ready this is what we call blocking or synchronous architecture and that's how applications built with frameworks like a speed net or rails work out of the box so when we receive a request on the server a thread is allocated to handle that request as part of handling that requests it is likely that we're going to query a database and as you know sometimes it may take a little while until the result is ready when the database is executing the query that thread is sitting there waiting it can't be used to serve another client so we need a new thread to serve another client imagine what would happen if we have a large number of concurrent clients at some point we're going to run out of threads to serve these clients so new clients have to wait until three threads are available or if we don't want them to wait we need to add more hardware so with this kind of architecture we are not utilizing our resources efficiently this is the problem with blocking or synchronous architecture and as I explained that's how applications built with frameworks like asp.net worked by default of course in asp.net it is possible to use asynchronous architecture but you will have to do extra work for now in contrast no the applications are asynchronous by default so you don't have to do anything extra in node we have a single thread to handle all requests linear request arrives that single thread is used to handle that request if you need to query a database our thread doesn't have to wait for the database to return the data while the database is executing our query that thread will be used to serve another client when the database prepares the result it puts a message in what we call an event queue node is continuously monitoring this queue in the background when it finds an event in this queue it will take it out and process it this kind of architecture makes node ideal for building applications that include a lot of disk or network access we can serve more clients without the need to throw in more hardware and that's why no the applications are highly scalable in contrast node should not be used for CPU intensive applications like a video encoding or an image manipulation service in this kind of applications we have a lot of calculations that should be done by CPU and few operations that touch the file system or the network since no the applications are single threaded when performing the calculations to serve one client other clients have to wait and that's why note should not be used or CPU intensive applications it should only be used for building data intensive and real-time applications ok enough theory Nix I'm gonna show you how to install node and build your first node application hi guys its mosh here thank you for watching my know tutorial I just wanted to let you know that this video you've been watching it's part of my complete note course where you will learn everything about node from the basic to the advanced topics if you're serious about learning node I highly recommend you to enroll in my node course because this is much faster than jumping from one tutorial to another it saves you time plus you're going to get a lot of exercises that will prepare you for the real work and also at the end of the course you'll receive a certificate of completion that you can provide your current or future employer so if you want to enroll click on the link in the video description I hope to see you in the course

Original Description

Node tutorial for beginners: https://youtu.be/TlB_eWDSMt4 Learn and understand the single-threaded, non-blocking (asynchronous) I/O model in Node.js. Subscribe for more videos: https://www.youtube.com/channel/UCWv7vMbMWH4-V0ZXdmDpPBA?sub_confirmation=1 Want to learn more from me? Check out my blog and courses: http://programmingwithmosh.com https://www.facebook.com/programmingwithmosh/ https://twitter.com/moshhamedani
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Programming with Mosh · Programming with Mosh · 0 of 60

← Previous Next →
1 6 Visual Studio Tips to Increase Your Productivity | Mosh
6 Visual Studio Tips to Increase Your Productivity | Mosh
Programming with Mosh
2 Visual Studio Keyboard Shortcuts that Speed Up Debugging Applications | Mosh
Visual Studio Keyboard Shortcuts that Speed Up Debugging Applications | Mosh
Programming with Mosh
3 Backbone.js Tutorial Part 2 - Backbone.js Models: Working with Model Attributes
Backbone.js Tutorial Part 2 - Backbone.js Models: Working with Model Attributes
Programming with Mosh
4 Backbone.js Tutorial Part 3 - Backbone.js Models: Model Validation
Backbone.js Tutorial Part 3 - Backbone.js Models: Model Validation
Programming with Mosh
5 Backbone.js Tutorial Part 4 - Backbone.js Models: Model Inheritance
Backbone.js Tutorial Part 4 - Backbone.js Models: Model Inheritance
Programming with Mosh
6 Backbone.js Tutorial Part 1 - Backbone.js Models: Creating Models
Backbone.js Tutorial Part 1 - Backbone.js Models: Creating Models
Programming with Mosh
7 Backbone.js Tutorial Part 5 - Backbone.js Models: Syncing Models with the Server
Backbone.js Tutorial Part 5 - Backbone.js Models: Syncing Models with the Server
Programming with Mosh
8 Backbone.js Tutorial Part 6 - Backbone.js Collections: Creating Collections
Backbone.js Tutorial Part 6 - Backbone.js Collections: Creating Collections
Programming with Mosh
9 Backbone.js Tutorial Part 7 - Backbone.js Collections: Working with Collections
Backbone.js Tutorial Part 7 - Backbone.js Collections: Working with Collections
Programming with Mosh
10 Backbone.js Tutorial Part 8 - Backbone.js Collections: Fetching Collections from the Server
Backbone.js Tutorial Part 8 - Backbone.js Collections: Fetching Collections from the Server
Programming with Mosh
11 Backbone.js Tutorial Part 9 - Backbone.js Views: Creating Views
Backbone.js Tutorial Part 9 - Backbone.js Views: Creating Views
Programming with Mosh
12 Backbone.js Tutorial Part 10 - Backbone.js Views: Passing Data to Views
Backbone.js Tutorial Part 10 - Backbone.js Views: Passing Data to Views
Programming with Mosh
13 Backbone.js Tutorial Part 11 - Backbone.js Views: Handling the DOM Events
Backbone.js Tutorial Part 11 - Backbone.js Views: Handling the DOM Events
Programming with Mosh
14 Backbone.js Tutorial Part 12 - Backbone.js Views: Handling the Model Events
Backbone.js Tutorial Part 12 - Backbone.js Views: Handling the Model Events
Programming with Mosh
15 Backbone.js Tutorial Part 13 - Backbone.js Views: Handling Collection Events
Backbone.js Tutorial Part 13 - Backbone.js Views: Handling Collection Events
Programming with Mosh
16 Backbone.js Tutorial Part 14 - Backbone.js Views: Templating
Backbone.js Tutorial Part 14 - Backbone.js Views: Templating
Programming with Mosh
17 Clean Code: Learn to write clean, maintainable and robust code
Clean Code: Learn to write clean, maintainable and robust code
Programming with Mosh
18 C# Events and Delegates Made Simple | Mosh
C# Events and Delegates Made Simple | Mosh
Programming with Mosh
19 C# Generics Tutorial: Whats and Whys | Mosh
C# Generics Tutorial: Whats and Whys | Mosh
Programming with Mosh
20 Debugging C# Code in Visual Studio | Mosh
Debugging C# Code in Visual Studio | Mosh
Programming with Mosh
21 Repository Pattern with C# and Entity Framework, Done Right | Mosh
Repository Pattern with C# and Entity Framework, Done Right | Mosh
Programming with Mosh
22 Angular 2 Tutorial for Beginners: Learn Angular 2 from Scratch | Mosh
Angular 2 Tutorial for Beginners: Learn Angular 2 from Scratch | Mosh
Programming with Mosh
23 Architecture of Angular 2+ Apps
Architecture of Angular 2+ Apps
Programming with Mosh
24 Working with Components in Angular
Working with Components in Angular
Programming with Mosh
25 C# Tutorial For Beginners - Learn C# Basics in 1 Hour
C# Tutorial For Beginners - Learn C# Basics in 1 Hour
Programming with Mosh
26 Difference between Junior and Senior Developers
Difference between Junior and Senior Developers
Programming with Mosh
27 Step-by-step ASP.NET MVC Tutorial for Beginners | Mosh
Step-by-step ASP.NET MVC Tutorial for Beginners | Mosh
Programming with Mosh
28 [Pluralsight]: Become a Full-stack .NET Developer
[Pluralsight]: Become a Full-stack .NET Developer
Programming with Mosh
29 Xamarin Forms Tutorial: Build Native Mobile Apps with C#
Xamarin Forms Tutorial: Build Native Mobile Apps with C#
Programming with Mosh
30 Value Types and Reference Types in JavaScript
Value Types and Reference Types in JavaScript
Programming with Mosh
31 Using Redux in Angular 2+ Apps | Mosh
Using Redux in Angular 2+ Apps | Mosh
Programming with Mosh
32 Testing Angular 2+ Apps with Jasmine and Karma | Mosh
Testing Angular 2+ Apps with Jasmine and Karma | Mosh
Programming with Mosh
33 Profile and optimize your Angular 2 apps
Profile and optimize your Angular 2 apps
Programming with Mosh
34 Build a Real-world App with ASP.NET Core and Angular 2
Build a Real-world App with ASP.NET Core and Angular 2
Programming with Mosh
35 Entity Framework 6 Tutorial: Learn Entity Framework 6 from Scratch
Entity Framework 6 Tutorial: Learn Entity Framework 6 from Scratch
Programming with Mosh
36 Two-way Binding and ngModel in Angular 4
Two-way Binding and ngModel in Angular 4
Programming with Mosh
37 Udemy Live 2017: Teaching Tech Panel
Udemy Live 2017: Teaching Tech Panel
Programming with Mosh
38 Demo of An E-commerce App Built with Angular, Firebase and Bootstrap 4
Demo of An E-commerce App Built with Angular, Firebase and Bootstrap 4
Programming with Mosh
39 My Brand New Angular Course
My Brand New Angular Course
Programming with Mosh
40 TypeScript Tutorial - TypeScript for React - Learn TypeScript
TypeScript Tutorial - TypeScript for React - Learn TypeScript
Programming with Mosh
41 Access Modifiers in TypeScript
Access Modifiers in TypeScript
Programming with Mosh
42 TypeScript Interfaces
TypeScript Interfaces
Programming with Mosh
43 TypeScript Classes
TypeScript Classes
Programming with Mosh
44 TypeScript Constructors
TypeScript Constructors
Programming with Mosh
45 TypeScript Properties
TypeScript Properties
Programming with Mosh
46 Angular Tutorial for Beginners: Learn Angular & TypeScript
Angular Tutorial for Beginners: Learn Angular & TypeScript
Programming with Mosh
47 AngularJS vs Angular 2 vs Angular 4 | Mosh
AngularJS vs Angular 2 vs Angular 4 | Mosh
Programming with Mosh
48 Angular Material Tutorial | Mosh
Angular Material Tutorial | Mosh
Programming with Mosh
49 Angular Animations Tutorial | Mosh
Angular Animations Tutorial | Mosh
Programming with Mosh
50 Firebase in Angular Applications | Mosh
Firebase in Angular Applications | Mosh
Programming with Mosh
51 Deploying Angular Applications | Mosh
Deploying Angular Applications | Mosh
Programming with Mosh
52 Building Forms in Angular Apps | Mosh
Building Forms in Angular Apps | Mosh
Programming with Mosh
53 Directives in Angular Applications
Directives in Angular Applications
Programming with Mosh
54 Routing and Navigation in Angular | Mosh
Routing and Navigation in Angular | Mosh
Programming with Mosh
55 Angular 4 in 40 Minutes
Angular 4 in 40 Minutes
Programming with Mosh
56 [NEW COURSE] Unit Testing for C# Developers
[NEW COURSE] Unit Testing for C# Developers
Programming with Mosh
57 Unit Testing C# Code - Tutorial for Beginners
Unit Testing C# Code - Tutorial for Beginners
Programming with Mosh
58 C# Classes Tutorial | Mosh
C# Classes Tutorial | Mosh
Programming with Mosh
59 C# Object Initializers Tutorial
C# Object Initializers Tutorial
Programming with Mosh
60 C# Constructors Tutorial | Mosh
C# Constructors Tutorial | Mosh
Programming with Mosh

This video teaches the basics of Node.js, including its single-threaded, non-blocking I/O model, and how it differs from blocking or synchronous architecture. It also demonstrates how to install Node and build a first Node application. By understanding these concepts, developers can build scalable and efficient Node.js applications.

Key Takeaways
  1. Install Node.js
  2. Create a new Node.js project
  3. Understand the event queue and event loop in Node.js
  4. Use asynchronous programming to handle concurrent requests
  5. Build a simple Node.js application to demonstrate scalability
💡 Node.js is ideal for building data-intensive and real-time applications, but not suitable for CPU-intensive applications like video encoding or image manipulation.

Related Reads

📰
How I Built a Blank Page Detector for PDFs with Vue 3 and Canvas
Learn to build a blank page detector for PDFs using Vue 3 and Canvas to automate the removal of blank pages
Dev.to · sunshey
📰
What I Learned Building an AI Resume Optimizer — And What Recruiters Actually Told Me
Learn how to build an AI-powered resume optimizer and what recruiters think about AI-optimized resumes
Dev.to · dayu2333-jinyul
📰
The Language Barrier That Made Me Use AI Better
Discover how overcoming language barriers with AI can improve development workflows and community engagement
Dev.to · FromZeroToShip
📰
I Stopped Running Playwright in Cron and Built a Screenshot Archive Instead
Learn to automate website screenshot capture without relying on cron jobs, using a Python workflow with Playwright
Dev.to · Cizze R
Up next
15 NotebookLM Hacks That Change How You Work
SCALER
Watch →