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
Scaling NodeJS beyond the ordinary
Search
Abhinav Rastogi
March 02, 2018
Technology
0
300
Scaling NodeJS beyond the ordinary
These are the slides to accompany the talk I gave at JSConf Iceland 2018.
Abhinav Rastogi
March 02, 2018
Tweet
Share
More Decks by Abhinav Rastogi
See All by Abhinav Rastogi
Next Gen Web: Scaling Progressive Web Apps
abhinavrastogi
57
14k
Other Decks in Technology
See All in Technology
QuickSight SPICE の効果的な運用戦略~S3 + Athena 構成での実践ノウハウ~/quicksight-spice-s3-athena-best-practices
emiki
0
270
セキュアなAI活用のためのLiteLLMの可能性
tk3fftk
1
230
マルチプロダクト環境におけるSREの役割 / SRE NEXT 2025 lunch session
sugamasao
1
590
american airlines®️ USA Contact Numbers: Complete 2025 Support Guide
supportflight
1
120
CDK Vibe Coding Fes
tomoki10
1
600
推し書籍📚 / Books and a QA Engineer
ak1210
0
120
SRE不在の開発チームが障害対応と 向き合った100日間 / 100 days dealing with issues without SREs
shin1988
2
1.7k
オフィスビルを監視しよう:フィジカル×デジタルにまたがるSLI/SLO設計と運用の難しさ / Monitoring Office Buildings: The Challenge of Physical-Digital SLI/SLO Design & Operation
bitkey
1
370
三視点LLMによる複数観点レビュー
mhlyc
0
120
Lakebaseを使ったAIエージェントを実装してみる
kameitomohiro
0
190
VS CodeとGitHub Copilotで爆速開発!アップデートの波に乗るおさらい会 / Rapid Development with VS Code and GitHub Copilot: Catch the Latest Wave
yamachu
2
390
20250708オープンエンドな探索と知識発見
sakana_ai
PRO
4
960
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
A better future with KSS
kneath
238
17k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
The Cult of Friendly URLs
andyhume
79
6.5k
We Have a Design System, Now What?
morganepeng
53
7.7k
Scaling GitHub
holman
460
140k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.4k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Transcript
Scaling NodeJS Beyond the ordinary Abhinav Rastogi Lead UI Engineer
_abhinavrastogi
None
150M Registered Users 500K Phones sold in 15 seconds 200M
Visits over 5 days during annual sale event
– Andre Bondi “Scalability is the capability of a system
to handle a growing amount of work, or its potential to be enlarged to accommodate that growth.”
Why should it concern the JS community?
Why should it concern the JS community? • JS is
running on servers now • Failure is shifting to application code • Failure is better handled by devs
Types of Scalability x y z Add more machines Add
more resources Application layer
Horizontal Scaling
Horizontal Scaling Machine Node API
Horizontal Scaling Machine Node API Machine Node ELB
Vertical Scaling
Vertical Scaling Machine Node API
Vertical Scaling Machine Node API Node ??
Application Layer Optimisations
The Optimisation Cycle Load Test Find Bottleneck Fix Issues
network, cpu, memory, disk
network bandwidth
network bandwidth
1000 kb per page 100 rps per machine 100 machines
= 10gbps
compression
const app = express() app.use(compression)
co-hosted nginx
co-hosted nginx Machine Node Node PM2 nginx API ELB
network profiling
netstat / ss lsof watch
everything is a file in unix!
ulimit
ulimit core file size (blocks, -c) 0 file size (blocks,
-f) unlimited pending signals (-i) 32767 max locked memory (kbytes, -l) 32 max memory size (kbytes, -m) unlimited open files (-n) 1024 max user processes (-u) 50
increase the limits / reduce the usage
keep-alive header
keep-alive header Object.assign(headers, { 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=200' });
connection pooling
connection pooling const http = require('http'); fetch(url, { agent: new
http.Agent({ keepAlive: true, maxSockets: 24 }) });
ephemeral ports
tcp connection states
tcp connection states source: http://cnp3book.info.ucl.ac.be/1st/html/transport/transport.html
tcp connection states
cpu
cpu profiling
node --prof app.js
import crypto from 'crypto'; app.get('/auth', (req, res) => { const
hash = crypto.pbkdf2Sync(password, users[username].salt, 100, 512); if (users[username].hash.toString() === hash.toString()) { res.sendStatus(200); } else { res.sendStatus(401); } });
[Summary]: ticks total nonlib name 79 0.2% 0.2% JavaScript 36703
97.2% 99.2% C++ 7 0.0% 0.0% GC 767 2.0% Shared libraries 215 0.6% Unaccounted
[C++]: ticks total nonlib name 19557 51.8% 52.9% node::crypto::PBKDF2(v8) 4510
11.9% 12.2% _sha1_block_data_order 3165 8.4% 8.6% _malloc_zone_malloc
None
$ npm install -g 0x $ 0x app.js
None
disk
memory
real-time monitoring
load, profile, fix, repeat!
thank you @_abhinavrastogi http://tiny.cc/scalingnodejs