Traffic
Usual days
Traffic
Usual days
BBD
Top level Load balancer (Nginx)
Front End Load balancer (Nginx)
PM2
Node Instances
flipkart.com
API boxes, mSite etc.
n instances
PM2
Node Instances
..........................
Traffic
BBD
Top level Load balancer (Nginx)
Front End Load balancer (Nginx)
Node
Content
1MB
Let's understand this with a scenario
Your target: 10,000 qps
Response payload: 1MB
Total bandwidth required: 10,000 MB/s
1GB = 1000MB*
So do the math :P
For 10,000 qps we need
10GBps
1 GBps line
Node
Content
1MB
...... n instances
Assume,
I like to create suspense and build-up :P
var compression = require('compression');
var express = require('express');
var app = express();
app.use(compression());
Raise your hands please!
is
Top level Load balancer (Nginx)
Front End Load balancer (Nginx)
PM2 managed Node instances
PM2 managed Node instances
.................. n instances
Now, also GZIPing for us
Traffic
BBD
Top level Load balancer (Nginx)
Front End Load balancer (Nginx)
PM2 managed Node instances
PM2 managed Node instances
.................. n instances
GZIPing
BOTTLENECK!
Top level Load balancer (Nginx)
Front End Load balancer (Nginx)
PM2 managed Node instances
PM2 managed Node instances
.................. n instances
GZIPing
Nginx
Nginx
Co-hosted Nginx and Node on the same box
Traffic
BBD
With better roads, comes bigger cars!
Node
from Node, call APIs to get the data
generate HTML
req
Node
from Node, call APIs to get the data
generate HTML
req
1
2
3
Suspicious candidate for bottleneck? 1, 2 or 3?
http://api.server:80/
API Server
Node
http://my.server:8080/
http://p.q.r.s:80/
API Server
Node
http://a.b.c.d:8080/
Src IP
Src Port
Dest IP
Dest Port
a.b.c.d
p.q.r.s
80
a.b.c.d
p.q.r.s
80
a.b.c.d
p.q.r.s
80
a.b.c.d
p.q.r.s
80
Ephemeral Ports (32768 - 61000)
32769
32770
32771
32772
# Linux
$ cat /proc/sys/net/ipv4/ip_local_port_range
32768 61000