1 of 23

This slide is fully unuseful and created special for @artyomtrityak

2 of 23

Node.js вширь и вглубь

Horizontal scaling of Node.js applications.

Replication and Sharding MongoDB.

Performance tuning and load balancing.

Дмитрий Гусев

Синяками, шишками и опытом делится:

3 of 23

Node.js вширь и вглубь\ Node.js immortal

- is for YOUR imagination and experience

Дмитрий Гусев

4 of 23

Node.js вширь и вглубь\ Node.js immortal

  • Sooner or later, something will break
    • The third-party API service would be updated
    • Dependency would be removed from npm
  • When something goes wrong, it is important to know what
    • Error-stack
    • sms/email/call
    • ...

Дмитрий Гусев

5 of 23

Node.js вширь и вглубь\ Node.js immortal

  • Let’s try to make NodeJS application immortal
    • Cluster: master + workers
    • exception handling
      • -> email/sms/whatever
    • Process managers

Дмитрий Гусев

6 of 23

Node.js вширь и вглубь\ Node.js immortal

What if…

Cluster + exception handling + notifications + process managers

=

Дмитрий Гусев

7 of 23

Node.js вширь и вглубь\ Process managers

  • Pm2
  • StrongLoop
  • Forever
  • Nodemon
  • ...

Дмитрий Гусев

8 of 23

Node.js вширь и вглубь\ PM2

Дмитрий Гусев

9 of 23

Node.js вширь и вглубь\ PM2 -> keymetrics

Дмитрий Гусев

10 of 23

Node.js вширь и вглубь\ MongoDB\ Replication \ 0

Дмитрий Гусев

11 of 23

Node.js вширь и вглубь\ MongoDB\ Replication \ 1

Дмитрий Гусев

12 of 23

Node.js вширь и вглубь\ MongoDB\ Replication \ action

Дмитрий Гусев

13 of 23

Node.js вширь и вглубь\ MongoDB\ Sharding

Дмитрий Гусев

14 of 23

Node.js вширь и вглубь\ bash

Дмитрий Гусев

Let the bash be with you.

15 of 23

Node.js вширь и вглубь\ sysctl

Дмитрий Гусев

sysctl

16 of 23

Node.js вширь и вглубь\ sysctl

Дмитрий Гусев

It does not matter how much, the main thing that had a lot of. © Y. G.

17 of 23

Node.js вширь и вглубь\ sysctl

Дмитрий Гусев

  • Increase size of file handles and inode cache
    • fs.file-max = 2097152
  • Decrease the time default value for connections to keep alive
    • net.ipv4.tcp_keepalive_time = 300
    • net.ipv4.tcp_keepalive_probes = 5
    • net.ipv4.tcp_keepalive_intvl = 15
  • ...

18 of 23

Node.js вширь и вглубь\ load balancing

Дмитрий Гусев

  • Load balancer
  • Programmatical balancing
  • DNS balancing
  • Programmatical DNS balancing
  • ...

19 of 23

Node.js вширь и вглубь\ load balancing

Дмитрий Гусев

20 of 23

Node.js вширь и вглубь\ load balancing

Дмитрий Гусев

  • Load balancer / Programmatical balancing
    • - Could be expensive
    • - Could be broken
    • + Well controlled
    • + healthchecks
  • DNS balancing
    • - healthchecks
    • -+ smooth control
    • + cheap
    • + could not be broken
  • Programmatical DNS balancing
    • + cheap
    • + healthchecks
    • + well controlled
    • +-could not be broken
  • ...

21 of 23

Node.js вширь и вглубь\ Scaling alternatives

Дмитрий Гусев

22 of 23

Node.js вширь и вглубь\ Scaling alternatives

Дмитрий Гусев

23 of 23

Node.js вширь и вглубь\ System and performance monitoring

Дмитрий Гусев

  • Keymetrics
  • Monitorix
  • top/htop
  • ...