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

Scaling NodeJS beyond the ordinary

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

More Decks by Abhinav Rastogi

Other Decks in Technology

Transcript

  1. 150M Registered Users 500K Phones sold in 15 seconds 200M

    Visits over 5 days during annual sale event
  2. – 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.”
  3. 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
  4. Types of Scalability x y z Add more machines Add

    more resources Application layer
  5. 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
  6. connection pooling const http = require('http'); fetch(url, { agent: new

    http.Agent({ keepAlive: true, maxSockets: 24 }) });
  7. cpu

  8. 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); } });
  9. [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
  10. [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