Load Balancer
upstream app_example {
zone backend 64k;
least_conn;
server 127.0.0.1:9000 max_fails=3 fail_timeout=30s;
server 127.0.0.1:9001 max_fails=3 fail_timeout=30s;
server 127.0.0.1:9002 max_fails=3 fail_timeout=30s;
}
!
server {
!
# usual stuff omitted
!
location / {
health_check;
include proxy_params;
!
proxy_pass http://app_example/;
!
# Handle Web Socket connections
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Proxy
“Upstream”
Slide 18
Slide 18 text
Load Balancer
Upstream:
upstream app_example {
zone backend 64k;
least_conn;
server 127.0.0.1:9000 max_fails=3 fail_timeout=30s;
server 127.0.0.1:9001 max_fails=3 fail_timeout=30s;
server 127.0.0.1:9002 max_fails=3 fail_timeout=30s;
}
Servers & Algorithm
Slide 19
Slide 19 text
Load Balancer
Proxy Pass:
• Health Check
• Proxy
• Web Sockets
!
server {
!
# usual stuff omitted
!
location / {
health_check;
include proxy_params;
!
proxy_pass http://app_example/;
!
# Handle Web Socket connections
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Slide 20
Slide 20 text
Nginx as a
Web Cache
Slide 21
Slide 21 text
Web Cache
• Static Files - Caches static files, following
Cache-Control header rules as per HTTP spec
• Dynamic Requests - Can cache results of
dynamic (HTTP, FastCGI & uWSGI, etc) requests!
• Works with Load Balancing - Do all the
things for all the requests!
Caches all the things
Slide 22
Slide 22 text
Web Cache
• Cache Server - Server (Nginx) which does
web caching, pays attention to cache headers
• Origin Server - Server containing actual
resources that the cache server caches.
Determines “Cache Policy”
Terminology