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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Abhinav Rastogi
March 02, 2018
Technology
0
310
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
【2026年版】生成AIによる情報システムへのインパクト
taka_aki
0
170
OCI技術資料 : 外部接続 VPN接続 詳細
ocise
1
10k
Claude Codeで実践するスペック駆動開発入門 / sdd-with-claude_code
yoshidashingo
3
4.4k
EKSで実践する オブザーバビリティの現在地
honmarkhunt
2
300
Java ランタイムからカスタムランタイムに行き着くまで
ririru0325
0
110
Snowflakeデータ基盤で挑むAI活用 〜4年間のDataOpsの基礎をもとに〜
kaz3284
1
120
Agent Payments Protocolで実装するAIエージェント間取引
tokio007
0
160
既存のログ監視システムをクラウドっぽく実装してみた
tjmtrhs
0
190
Agentic Codingの実践とチームで導入するための工夫
lycorptech_jp
PRO
0
140
Databricks (と気合い)で頑張るAI Agent 運用
kameitomohiro
0
230
なぜAIは組織を速くしないのか 令和の腑分け
sugino
3
210
欲しいを叶える個人開発の進め方 / How to Run an Indie Project That Brings Your Ideas to Life
endohizumi
0
340
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Deep Space Network (abreviated)
tonyrice
0
76
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
190
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
63
53k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8k
ラッコキーワード サービス紹介資料
rakko
1
2.4M
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
We Are The Robots
honzajavorek
0
180
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
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