Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Node.js Scalability Myth

The Node.js Scalability Myth

Presentation given at the BerlinJS user group on March 15, 2012.

Felix Geisendörfer

March 16, 2012
Tweet

More Decks by Felix Geisendörfer

Other Decks in Programming

Transcript

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

    View full-size slide

  2. (@)felixge(.de)

    View full-size slide

  3. transloadit.com
    (using node since v0.0.6)

    View full-size slide

  4. core contributor

    View full-size slide

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

    View full-size slide

  6. Easy! I will use
    node.js and
    MongoDB!

    View full-size slide

  7. Easy! I will use
    node.js and
    MongoDB!

    View full-size slide

  8. Because node.js is
    “scalable”, right?

    View full-size slide

  9. Backend Developers?

    View full-size slide

  10. Are you measuring app performance in production?

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. Vertical Scalability

    View full-size slide

  16. Adding more resources to a single node

    View full-size slide

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

    View full-size slide

  18. Computers of the
    future will have
    hundreds of cores!

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  22. 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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  25. Horizontal Scalability

    View full-size slide

  26. Adding more nodes to a system

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  32. Questions?
    Slides will be available at felixge.de

    View full-size slide