SlideShare a Scribd company logo
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
•
•
•
•
•
•
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
const crypto = require('crypto');
const NUM_REQUESTS = 2;
for (let i = 0; i < NUM_REQUESTS; i++) {
crypto.pbkdf2Sync('secret', 'salt', 10000, 512, 'sha512');
}
0 50 100 150 200 250 300 350 400
Time (milliseconds)
Execution Timeline
const crypto = require('crypto');
const NUM_REQUESTS = 2;
for (let i = 0; i < NUM_REQUESTS; i++) {
crypto.pbkdf2('secret', 'salt', 10000, 512, 'sha512', () => {});
}
0 50 100 150 200 250 300 350 400
Time (milliseconds)
Execution Timeline
0 50 100 150 200 250 300 350 400
Time (milliseconds)
Execution Timeline
0 50 100 150 200 250 300 350 400
Time (milliseconds)
Execution Timeline
0 50 100 150 200 250 300 350 400
Time (milliseconds)
Execution Timeline
2 Requests
4 Requests
6 Requests
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
const https = require('https');
const NUM_REQUESTS = 2;
for (let i = 0; i < NUM_REQUESTS; ++i) {
https.request('https://nebri.us/static/me.jpg', (res) => {
res.on('data', () => {});
res.on('end', () => {});
}).end();
}
0 100 200 300 400 500 600 700 800
Time (milliseconds)
Execution Timeline
0 100 200 300 400 500 600 700 800
Time (milliseconds)
Execution Timeline
0 100 200 300 400 500 600 700 800
Time (milliseconds)
Execution Timeline
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
•
•
•
•
•
•
•
•
•
•
•
•
•
Bryan Hughes, @nebrius
Ad

More Related Content

What's hot (20)

Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
OdessaJS Conf
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
OdessaJS Conf
 
Correcting Common Async/Await Mistakes in .NET
Correcting Common Async/Await Mistakes in .NETCorrecting Common Async/Await Mistakes in .NET
Correcting Common Async/Await Mistakes in .NET
Brandon Minnick, MBA
 
Arp
ArpArp
Arp
Ebsil Sherly
 
Nginx-lua
Nginx-luaNginx-lua
Nginx-lua
Дэв Тим Афс
 
Workflow && t1k
Workflow && t1kWorkflow && t1k
Workflow && t1k
Rodrigo Maia
 
DESTRUCTOR EXAMPLES
DESTRUCTOR EXAMPLESDESTRUCTOR EXAMPLES
DESTRUCTOR EXAMPLES
srishti80
 
Kotlin Coroutines - the new async
Kotlin Coroutines - the new asyncKotlin Coroutines - the new async
Kotlin Coroutines - the new async
Bartłomiej Osmałek
 
Tracing and awk in ns2
Tracing and awk in ns2Tracing and awk in ns2
Tracing and awk in ns2
Pradeep Kumar TS
 
Circuit breaker
Circuit breakerCircuit breaker
Circuit breaker
bricemciver
 
Snake.c
Snake.cSnake.c
Snake.c
Vijay Singh
 
Linked list
Linked listLinked list
Linked list
Lovelyn Rose
 
Fast HTTP string processing algorithms
Fast HTTP string processing algorithmsFast HTTP string processing algorithms
Fast HTTP string processing algorithms
Alexander Krizhanovsky
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
Yasuharu Nakano
 
An Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB PluginsAn Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB Plugins
Takahiro Inoue
 
Closures for Java
Closures for JavaClosures for Java
Closures for Java
nextlib
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascript
Pavel Volokitin
 
Asynchronní programování
Asynchronní programováníAsynchronní programování
Asynchronní programování
PeckaDesign.cz
 
Alt.Net Presentation
Alt.Net PresentationAlt.Net Presentation
Alt.Net Presentation
Shohre Mansouri
 
Debugging, a step away from the console
Debugging, a step away from the consoleDebugging, a step away from the console
Debugging, a step away from the console
Adam Weeks
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
OdessaJS Conf
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
OdessaJS Conf
 
Correcting Common Async/Await Mistakes in .NET
Correcting Common Async/Await Mistakes in .NETCorrecting Common Async/Await Mistakes in .NET
Correcting Common Async/Await Mistakes in .NET
Brandon Minnick, MBA
 
DESTRUCTOR EXAMPLES
DESTRUCTOR EXAMPLESDESTRUCTOR EXAMPLES
DESTRUCTOR EXAMPLES
srishti80
 
Fast HTTP string processing algorithms
Fast HTTP string processing algorithmsFast HTTP string processing algorithms
Fast HTTP string processing algorithms
Alexander Krizhanovsky
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
Yasuharu Nakano
 
An Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB PluginsAn Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB Plugins
Takahiro Inoue
 
Closures for Java
Closures for JavaClosures for Java
Closures for Java
nextlib
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascript
Pavel Volokitin
 
Asynchronní programování
Asynchronní programováníAsynchronní programování
Asynchronní programování
PeckaDesign.cz
 
Debugging, a step away from the console
Debugging, a step away from the consoleDebugging, a step away from the console
Debugging, a step away from the console
Adam Weeks
 

Similar to The Node.js Event Loop: Not So Single Threaded (8)

明日から使える(?)Rubyトリビア
明日から使える(?)Rubyトリビア明日から使える(?)Rubyトリビア
明日から使える(?)Rubyトリビア
Maki Toshio
 
WiFi Security Explained
WiFi Security ExplainedWiFi Security Explained
WiFi Security Explained
Somenath Mukhopadhyay
 
Ruxmon cve 2012-2661
Ruxmon cve 2012-2661Ruxmon cve 2012-2661
Ruxmon cve 2012-2661
snyff
 
Django cryptography
Django cryptographyDjango cryptography
Django cryptography
Erik LaBianca
 
It's all about the timing
It's all about the timingIt's all about the timing
It's all about the timing
SensePost
 
The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196
Mahmoud Samir Fayed
 
Dodging WebCrypto API Landmines
Dodging WebCrypto API LandminesDodging WebCrypto API Landmines
Dodging WebCrypto API Landmines
Ernie Turner
 
Deep dumpster diving 2010
Deep dumpster diving 2010Deep dumpster diving 2010
Deep dumpster diving 2010
RonnBlack
 
明日から使える(?)Rubyトリビア
明日から使える(?)Rubyトリビア明日から使える(?)Rubyトリビア
明日から使える(?)Rubyトリビア
Maki Toshio
 
Ruxmon cve 2012-2661
Ruxmon cve 2012-2661Ruxmon cve 2012-2661
Ruxmon cve 2012-2661
snyff
 
It's all about the timing
It's all about the timingIt's all about the timing
It's all about the timing
SensePost
 
The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196
Mahmoud Samir Fayed
 
Dodging WebCrypto API Landmines
Dodging WebCrypto API LandminesDodging WebCrypto API Landmines
Dodging WebCrypto API Landmines
Ernie Turner
 
Deep dumpster diving 2010
Deep dumpster diving 2010Deep dumpster diving 2010
Deep dumpster diving 2010
RonnBlack
 
Ad

More from Bryan Hughes (6)

Effective Documentation for Open Source Projects (Open Source 101 Version)
Effective Documentation for Open Source Projects (Open Source 101 Version) Effective Documentation for Open Source Projects (Open Source 101 Version)
Effective Documentation for Open Source Projects (Open Source 101 Version)
Bryan Hughes
 
Effective Documentation for Open Source Projects (SFNode Version)
Effective Documentation for Open Source Projects (SFNode Version)Effective Documentation for Open Source Projects (SFNode Version)
Effective Documentation for Open Source Projects (SFNode Version)
Bryan Hughes
 
Effective Documentation for Open Source Projects
Effective Documentation for Open Source ProjectsEffective Documentation for Open Source Projects
Effective Documentation for Open Source Projects
Bryan Hughes
 
Johnny five
Johnny fiveJohnny five
Johnny five
Bryan Hughes
 
So You Want to Build a Circuit
So You Want to Build a CircuitSo You Want to Build a Circuit
So You Want to Build a Circuit
Bryan Hughes
 
The Lesser Known Features of ECMAScript 6
The Lesser Known Features of ECMAScript 6The Lesser Known Features of ECMAScript 6
The Lesser Known Features of ECMAScript 6
Bryan Hughes
 
Effective Documentation for Open Source Projects (Open Source 101 Version)
Effective Documentation for Open Source Projects (Open Source 101 Version) Effective Documentation for Open Source Projects (Open Source 101 Version)
Effective Documentation for Open Source Projects (Open Source 101 Version)
Bryan Hughes
 
Effective Documentation for Open Source Projects (SFNode Version)
Effective Documentation for Open Source Projects (SFNode Version)Effective Documentation for Open Source Projects (SFNode Version)
Effective Documentation for Open Source Projects (SFNode Version)
Bryan Hughes
 
Effective Documentation for Open Source Projects
Effective Documentation for Open Source ProjectsEffective Documentation for Open Source Projects
Effective Documentation for Open Source Projects
Bryan Hughes
 
So You Want to Build a Circuit
So You Want to Build a CircuitSo You Want to Build a Circuit
So You Want to Build a Circuit
Bryan Hughes
 
The Lesser Known Features of ECMAScript 6
The Lesser Known Features of ECMAScript 6The Lesser Known Features of ECMAScript 6
The Lesser Known Features of ECMAScript 6
Bryan Hughes
 
Ad

Recently uploaded (20)

[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
NYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdfNYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdf
AUGNYC
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
Adobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREEAdobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREE
zafranwaqar90
 
How to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber PluginHow to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber Plugin
eGrabber
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts[gbgcpp] Let's get comfortable with concepts
[gbgcpp] Let's get comfortable with concepts
Dimitrios Platis
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
NYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdfNYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdf
AUGNYC
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb ClarkDeploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Deploying & Testing Agentforce - End-to-end with Copado - Ewenb Clark
Peter Caitens
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
Adobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREEAdobe Audition Crack FRESH Version 2025 FREE
Adobe Audition Crack FRESH Version 2025 FREE
zafranwaqar90
 
How to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber PluginHow to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber Plugin
eGrabber
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 

The Node.js Event Loop: Not So Single Threaded

  • 13. const crypto = require('crypto'); const NUM_REQUESTS = 2; for (let i = 0; i < NUM_REQUESTS; i++) { crypto.pbkdf2Sync('secret', 'salt', 10000, 512, 'sha512'); }
  • 14. 0 50 100 150 200 250 300 350 400 Time (milliseconds) Execution Timeline
  • 15. const crypto = require('crypto'); const NUM_REQUESTS = 2; for (let i = 0; i < NUM_REQUESTS; i++) { crypto.pbkdf2('secret', 'salt', 10000, 512, 'sha512', () => {}); }
  • 16. 0 50 100 150 200 250 300 350 400 Time (milliseconds) Execution Timeline
  • 17. 0 50 100 150 200 250 300 350 400 Time (milliseconds) Execution Timeline
  • 18. 0 50 100 150 200 250 300 350 400 Time (milliseconds) Execution Timeline
  • 19. 0 50 100 150 200 250 300 350 400 Time (milliseconds) Execution Timeline 2 Requests 4 Requests 6 Requests
  • 22. const https = require('https'); const NUM_REQUESTS = 2; for (let i = 0; i < NUM_REQUESTS; ++i) { https.request('https://nebri.us/static/me.jpg', (res) => { res.on('data', () => {}); res.on('end', () => {}); }).end(); }
  • 23. 0 100 200 300 400 500 600 700 800 Time (milliseconds) Execution Timeline
  • 24. 0 100 200 300 400 500 600 700 800 Time (milliseconds) Execution Timeline
  • 25. 0 100 200 300 400 500 600 700 800 Time (milliseconds) Execution Timeline
  翻译: