Nairi Harutyunyan
Big fan of JavaScript
nairihar99@gmail.com
@nairihar
You have a NodeJS server with 3k requests per second
Now You have 30k requests per second
Lots of requests
NodeJS
:8000
NodeJS
:8001
NodeJS
:8002
NGINX
:3000
r1
r2
r3
r4
r5
r1
r2
r3
r4
r5
Connections/Polling
NodeJS
:8000
NodeJS
:8001
NodeJS
:8002
NGINX
:3000
u1
req 1
req 2
polling req 1
polling req 2
res 1
Session ID unknown
Stop balance after user's first request
NodeJS
:8000
NodeJS
:8001
NodeJS
:8002
NGINX
:3000
u1
polling req 1
polling req 2
polling req 1
polling req 2
Server 1 can't send data to user 2
NodeJS
:8000
NodeJS
:8001
NodeJS
:8002
NGINX
:3000
u1
u1 connected to s1
u1 emits to s1 for u2
u1 connect to socket
u1 emit data for u2
u2
u2 connect to socket
u2 connected to s2
Error
REDIS
REDIS
NodeJS
:8000
NodeJS
:8001
subscribe
publish
publish
subscribe
Use Redis PUB/SUB with Sockets
NodeJS
:8000
NodeJS
:8001
NodeJS
:8002
NGINX
:3000
u1
u2
REDIS
Other Load Balancers
Thank You!
nairihar99@gmail.com
@nairihar
By Nairi Harutyunyan
NodeJS Load Balancing with Nginx and Redis PUB/SUB with Socket