Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The Node.js Scalability Myth
Search
Felix Geisendörfer
May 02, 2012
Technology
4
1.5k
The Node.js Scalability Myth
Presentation given on 26.04.2012 at MixIT conference in Lyon, France.
Felix Geisendörfer
May 02, 2012
Tweet
Share
More Decks by Felix Geisendörfer
See All by Felix Geisendörfer
tus.io - Resumable File Uploads (Lightning Talk)
felixge
2
730
Programming flying robots with JavaScript
felixge
2
910
Programming flying robots with JavaScript
felixge
0
550
Programming an AR Drone Firmware with JS (de)
felixge
1
580
Faster than C?
felixge
1
1.2k
Flying robots over a 10.000 mile distance with JavaScript.
felixge
0
450
Faster than C?
felixge
1
580
The power of node.js (with quadcopters)
felixge
0
460
Faster than C?
felixge
0
370
Other Decks in Technology
See All in Technology
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
2
2.1k
Storage Browser for Amazon S3
miu_crescent
1
120
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
520
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
250
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
160
MLOps の現場から
asei
6
630
Amazon Kendra GenAI Index 登場でどう変わる? 評価から学ぶ最適なRAG構成
naoki_0531
0
100
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
150
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
140
AIのコンプラは何故しんどい?
shujisado
1
190
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
180
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
150
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Producing Creativity
orderedlist
PRO
341
39k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
For a Future-Friendly Web
brad_frost
175
9.4k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Transcript
The Node.js Scalability Myth Felix Geisendörfer 26.04.2012 at MixIT Conference
(Lyon, France)
(@)felixge(.de)
core contributor
transloadit.com (using node since v0.0.6)
History
Ryan Dahl starts the node project (first commit) Feb 16,
2009
Discovered node.js (v0.0.6) ~June, 2009
None
Core Contributor & Module Author node-mysql node-formidable + 30 other
modules
Isaac Schlueter starts the npm package manager (first commit) Sep
29, 2009
Ryan’s talk at JSConf.EU gets people excited about node Nov
7, 2009
(c) @substack Jan 30, 2012 Ryan appoints Isaac to lead
node.js
Topic of this Talk
I need to build an über-scalable web service. It will
be the next big thing!
Easy! I will use node.js and MongoDB!
Easy! I will use node.js and MongoDB!
Because node.js is “scalable”, right?
None
Audience?
Node.js?
Are you measuring app performance in production?
1000 req / s
100 req / s
10 req / s
10 requests / per second = 864000 requests / day
10 req / s
The End?
I REALLY need to build an über-scalable web service!!11!1
Scalability
(c) @substack
The Node.js Scalability Myth • Threads don’t scale • Event
loops do
The Node.js Scalability Myth • Threads don’t scale • Event
loops do (Probably) not true in 2012 (Very likely) not relevant
More relevant • Understanding your tools • Using the right
tool for the job
Node’s Concurrency Model
Node’s Concurrency Model 1 var http = require('http'); 2 3
http.createServer(function(req, res) { 4 res.end('Hello World'); 5 }).listen(8080); server.js
Node’s Concurrency Model $ node server.js
Node’s Concurrency Model • Node loads server.js from disk ->
v8 compiles & executes • listen() allocates and binds a file descriptor • Event Loops starts running
Node’s Concurrency Model 1 while (true) { 2 int r
= select(nfds, readfds, writefds, errorfds, 0); 3 if (r === 0) { 4 continue; 5 } 6 7 // Figure out which fds had activity, accept() on server fds, read() on // connection fds, write() queued writes 8 } Abstracted by libuv Different on Windows
Node’s Concurrency Model • Cooperative multitasking • Low memory usage
• Fast / efficient • Simple (compared to threads)
Vertical Scalability
Adding more resources to a single node
Vertical Scalability • CPU • GPUs • Memory • Disk
• Network
CPU
CPU (v8) • V8 compiles JS to Assembly • Just-in-time
compilation (JIT) • Does pretty well in those language benchmarks
Computers of the future will have hundreds of cores!
CPU • Node is single threaded (runs on a single
CPU) • No shared memory
But ...
Does your problem require shared memory?
If yes: Don’t use node
And: Good Luck
If no: child_process.fork()
Redis / ZeroMQ are your friends
GPUs
GPUs • No support in node itself • node-cuda addon
by Kashif Rasul
Memory
Memory • No hard memory limit on 64 bit (since
node-0.6 / v8-3.7) • JS is a garbage collected language (avoid huge heaps) • Buffers do not count towards heap
Network
Network • Node’s concurrency model is optimized for networking •
Good at fully saturating available network resources
Disk
Disk • Done in thread pool • Unfortunately along with
DNS at this point • Throughput ok, but not ideal yet • sendfile() not working yet
Does node scale vertically?
Yeah, good enough
Horizontal Scalability
Adding more nodes to a system
Bad News
Node.js has no horizontal scaling features
Even worse
This s#@t is really hard
Problems • De-coupling / encapsulation • CAP Theorem • System
Automation
...
Good Luck
One tip
Monitor & Measure! • Collect: node-measured, statsd, ... • Analyze:
Graphite, Librato Metrics, ... • Debug
So if node doesn’t have magic scaling, what is it
good for?
<Live Coding>
tl;dr • Know your requirements • There are no silver
bullets
Questions? Slides will be available at felixge.de
Thanks
Feedback