Slide 1

Slide 1 text

The Node.js Scalability Myth Felix Geisendörfer 15.03.2012 at BerlinJS user group

Slide 2

Slide 2 text

(@)felixge(.de)

Slide 3

Slide 3 text

transloadit.com (using node since v0.0.6)

Slide 4

Slide 4 text

core contributor

Slide 5

Slide 5 text

I need to build an über-scalable web service. It will be the next big thing!

Slide 6

Slide 6 text

Easy! I will use node.js and MongoDB!

Slide 7

Slide 7 text

Easy! I will use node.js and MongoDB!

Slide 8

Slide 8 text

Because node.js is “scalable”, right?

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Audience?

Slide 11

Slide 11 text

Backend Developers?

Slide 12

Slide 12 text

Are you measuring app performance in production?

Slide 13

Slide 13 text

1000 req / s

Slide 14

Slide 14 text

100 req / s

Slide 15

Slide 15 text

10 req / s

Slide 16

Slide 16 text

10 requests / per second = 864000 requests / day 10 req / s

Slide 17

Slide 17 text

Scalability

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

The Node.js Scalability Myth • Threads don’t scale • Event loops do

Slide 20

Slide 20 text

The Node.js Scalability Myth • Threads don’t scale • Event loops do (Probably) not true in 2012 (Very likely) not relevant

Slide 21

Slide 21 text

More relevant • Understanding scalability • Using the right tool for the job

Slide 22

Slide 22 text

Vertical Scalability

Slide 23

Slide 23 text

Adding more resources to a single node

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Vertical Scalability • CPU • GPUs • Memory • Disk • Network

Slide 26

Slide 26 text

CPU

Slide 27

Slide 27 text

Computers of the future will have hundreds of cores!

Slide 28

Slide 28 text

CPU • Node is single threaded (runs on a single CPU) • Using multiple CPUs requires multiple node processes (usually via prefork) • No shared memory

Slide 29

Slide 29 text

CPU (v8) • V8 compiles JS to Assembly • Just-in-time compilation (JIT) • Does reasonably well in those language “benchmarks”

Slide 30

Slide 30 text

GPUs

Slide 31

Slide 31 text

GPUs • No support in node itself • node-cuda addon by Kashif Rasul

Slide 32

Slide 32 text

Memory

Slide 33

Slide 33 text

Memory • No hard memory limit on 64 bit (since node-0.6 / v8-3.6.5) • JS is a garbage collected language (avoid huge heaps) • Buffers do not count towards heap

Slide 34

Slide 34 text

Network

Slide 35

Slide 35 text

Network • Node’s network stack is a thin layer on top of underlaying system calls • Good at fully saturating network interfaces

Slide 36

Slide 36 text

Disk

Slide 37

Slide 37 text

Disk • Done in thread pool • Unfortunately along with DNS at this point • Throughput ok, but not ideal yet

Slide 38

Slide 38 text

Horizontal Scalability

Slide 39

Slide 39 text

Adding more nodes to a system

Slide 40

Slide 40 text

Horizontal Scalability • Node has no horizontal scaling specific features, but ... • Fast networking & JSON / Buffers -> DIY

Slide 41

Slide 41 text

Horizontal Scalability • Simple stack (requires only build tools, python) • Deployable without container server • Good package management via npm

Slide 42

Slide 42 text

Horizontal Solution “I have the full solution ...”

Slide 43

Slide 43 text

Horizontal Solution “... but unfortunately it did not fit on this slide”

Slide 44

Slide 44 text

tl;dr • Know your requirements • There are no silver bullets

Slide 45

Slide 45 text

Questions? Slides will be available at felixge.de

Slide 46

Slide 46 text

Thanks