SlideShare a Scribd company logo
Load Balancing and 
Scaling with NGINX 
Introduced by Andrew Alexeev 
Presented by Owen Garrett 
Nginx, Inc.
About this webinar 
When one server just isn’t enough, how can you scale out? In this 
webinar, you'll learn how to build out the capacity of your website. You'll 
see a variety of scalability approaches and some of the advanced 
capabilities of NGINX Plus.
INTRODUCING NGINX…
What is NGINX? 
Internet 
Proxy 
Caching, Load Balancing… HTTP traffic 
N 
Web Server 
Serve content from disk 
Application Server 
FastCGI, uWSGI, Passenger… 
Application Acceleration 
SSL and SPDY termination 
Performance Monitoring 
High Availability 
Advanced Features: Bandwidth Management 
Content-based Routing 
Request Manipulation 
Response Rewriting 
Authentication 
Video Delivery 
Mail Proxy 
GeoLocation
NGINX Accelerates 
143,000,000 
Websites
22% 
Top 1 million websites 37% 
Top 1,000 websites
NGINX and NGINX Plus 
NGINX F/OSS 
nginx.org 
3rd party 
modules 
Large community of >100 modules
NGINX and NGINX Plus 
NGINX F/OSS 
nginx.org 
3rd party 
modules 
Large community of >100 modules 
NGINX Plus 
Advanced load balancing features 
Ease-of-management 
Commercial support
WHY LOAD-BALANCE?
Load-balancing Web Servers 
Internet 
N 
 Improved Application Availability 
 Management 
 Increased Capacity 
 Advanced techniques e.g. A|B testing 
Why?  DNS Round Robin 
 Hardware L4 load balancer 
 Software Reverse Proxy LB 
 Cloud solution 
How?
Load Balancing and Scaling with NGINX
Three Load Balancing case studies 
Basic Load Balancing with NGINX 
When you need more control 
Advanced techniques 
1 
2 
3
1. Basic Load Balancing 
• Simple scalability 
– All servers have same applications/services 
– Load-balancer extracts optimal performance
Basic load balancing 
server { 
listen 80; 
location / { 
proxy_pass http://backend; 
} 
} 
upstream backend { 
zone backend 64k; 
server webserver1:80; 
server webserver2:80; 
server webserver3:80; 
server webserver4:80; 
}
Basic load balancing 
• Use logging to debug: “$upstream_addr” 
log_format combined2 '$remote_addr - $remote_user [$time_local] ' 
'"$request" $status $body_bytes_sent ' 
'"$upstream_addr"'; 
192.168.56.1 - - [09/Mar/2014:23:08:56 +0000] "GET / HTTP/1.1" 200 30 "127.0.1.1:80" 
192.168.56.1 - - [09/Mar/2014:23:08:56 +0000] "GET /favicon.ico HTTP/1.1" 200 30 "127.0.1.2:80" 
192.168.56.1 - - [09/Mar/2014:23:08:57 +0000] "GET / HTTP/1.1" 200 30 "127.0.1.3:80" 
192.168.56.1 - - [09/Mar/2014:23:08:57 +0000] "GET /favicon.ico HTTP/1.1" 200 30 "127.0.1.4:80" 
192.168.56.1 - - [09/Mar/2014:23:08:57 +0000] "GET / HTTP/1.1" 200 30 "127.0.1.1:80" 
192.168.56.1 - - [09/Mar/2014:23:08:57 +0000] "GET /favicon.ico HTTP/1.1" 200 30 "127.0.1.2:80" 
192.168.56.1 - - [09/Mar/2014:23:08:58 +0000] "GET / HTTP/1.1" 200 30 "127.0.1.3:80" 
192.168.56.1 - - [09/Mar/2014:23:08:58 +0000] "GET /favicon.ico HTTP/1.1" 200 30 "127.0.1.4:80"
Basic Load Balancing 
• Round-robin is the default 
– Suitable for consistent pages 
• Least Connections 
– Suitable for varying pages 
• IP Hash 
– Fixed mapping, basic session 
persistence 
upstream backend { 
server webserver1:80; 
server webserver2:80; 
} 
upstream backend { 
least_conn; 
server webserver1:80; 
server webserver2:80; 
} 
upstream backend { 
ip_hash; 
server webserver1:80; 
server webserver2:80; 
}
Managing the Upstream Group 
• Direct config editing: 
– nginx –s reload 
– upstream.conf file: 
upstream backend { 
server webserver1:80; 
server webserver2:80; 
server webserver3:80; 
server webserver4:80; 
} 
• On-the-fly Reconfiguration [NGINX Plus only] 
$ curl 'http://localhost/upstream_conf?upstream=backend&id=3&down=1'
2. When you need more control… 
• In many scenarios, you want more control over 
where traffic is routed to: 
– Primary and secondary servers (aka master/slave) 
– Transaction state is accumulated on one server
‘Master’ and ‘Slave’ servers 
• Wordpress admin traffic (e.g. image uploads) 
Internet 
N 
‘Master’ 
‘Slave’ 
Copy image 
uploads from 
master to slave
‘Master’ and ‘Slave’ servers 
• Wordpress admin traffic (e.g. image uploads) 
N 
server { 
listen 80; 
location ~ ^/(wp-admin|wp-login) { 
proxy_pass http://wpadmin; 
} 
} 
upstream wpadmin { 
server server1:80; 
server server2:80 backup; 
} 
‘Master’ 
‘Slave’
Session Persistence [NGINX Plus only] 
• For when transaction state is accumulated on one server 
– Shopping carts 
– Advanced interactions 
– Non-RESTful Applications 
• NGINX Plus offers two methods: 
– sticky cookie 
– sticky route 
“Session persistence also 
helps performance”
Advanced Techniques 
• You can control load-balancing programmatically 
– A|B Testing 
– Migration between applications
A|B Testing 
Internet 
N 
‘backends’ upstream group 
Test 
server 
95% 
5% 
Partition traffic. 
Send 5% to new application instance
A|B Testing 
split_clients "${remote_addr}AAA" $servers { 
95% backends; 
5% 192.168.56.1:80; 
} 
server { 
listen 80; 
location / { 
proxy_pass http://$servers; 
} 
}
Application Migration 
Internet 
N 
‘backendsA’ upstream group 
‘backendsB’ upstream group 
Create new generation of application 
Migrate users from old to new 
Preserve sessions, no interruptions
Application Migration 
map $cookie_group $group { 
~(?P<value>.+)$ $value; 
default backendB; # The default upstream group 
} 
server { 
listen 80; 
location / { 
add_header Set-Cookie "group=$group; path=/" 
proxy_pass http://$group; 
} 
}
Three Load Balancing case studies 
Basic Load Balancing with NGINX 
When you need more control 
Advanced techniques 
1 
2 
3
Closing thoughts 
• 37% of the busiest websites use NGINX 
• Check out the load-balancing articles on 
nginx.com/blog 
• Future webinars: nginx.com/webinars 
Try NGINX F/OSS (nginx.org) or NGINX Plus (nginx.com)

More Related Content

What's hot (20)

PPTX
NGINX: High Performance Load Balancing
NGINX, Inc.
 
PPT
Nginx internals
liqiang xu
 
PPTX
Learn nginx in 90mins
Larry Cai
 
PPTX
Apache kafka
Srikrishna k
 
PDF
NGINX: Basics and Best Practices EMEA
NGINX, Inc.
 
PPTX
Openstack zun,virtual kubelet
Chanyeol yoon
 
PDF
Automation with ansible
Khizer Naeem
 
PDF
Ansible 101
Gena Mykhailiuta
 
PDF
Nginx Essential
Gong Haibing
 
ODP
Introduction to Nginx
Knoldus Inc.
 
PPT
Docker introduction
Phuc Nguyen
 
PPTX
NGINX Installation and Tuning
NGINX, Inc.
 
PPTX
[오픈소스컨설팅]Ansible overview
Open Source Consulting
 
PDF
Cobbler - Fast and reliable multi-OS provisioning
RUDDER
 
PPTX
Jenkins CI
Viyaan Jhiingade
 
PPTX
Docker Networking - Common Issues and Troubleshooting Techniques
Sreenivas Makam
 
PDF
Ansible Introduction
Robert Reiz
 
PPTX
5 things you didn't know nginx could do
sarahnovotny
 
PPTX
Ansible presentation
Suresh Kumar
 
NGINX: High Performance Load Balancing
NGINX, Inc.
 
Nginx internals
liqiang xu
 
Learn nginx in 90mins
Larry Cai
 
Apache kafka
Srikrishna k
 
NGINX: Basics and Best Practices EMEA
NGINX, Inc.
 
Openstack zun,virtual kubelet
Chanyeol yoon
 
Automation with ansible
Khizer Naeem
 
Ansible 101
Gena Mykhailiuta
 
Nginx Essential
Gong Haibing
 
Introduction to Nginx
Knoldus Inc.
 
Docker introduction
Phuc Nguyen
 
NGINX Installation and Tuning
NGINX, Inc.
 
[오픈소스컨설팅]Ansible overview
Open Source Consulting
 
Cobbler - Fast and reliable multi-OS provisioning
RUDDER
 
Jenkins CI
Viyaan Jhiingade
 
Docker Networking - Common Issues and Troubleshooting Techniques
Sreenivas Makam
 
Ansible Introduction
Robert Reiz
 
5 things you didn't know nginx could do
sarahnovotny
 
Ansible presentation
Suresh Kumar
 

Similar to Load Balancing and Scaling with NGINX (20)

PPTX
Load Balancing Container with Nginx
Kumar Mayank
 
PDF
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
Ortus Solutions, Corp
 
PDF
What is Nginx and Why You Should to Use it with Wordpress Hosting
WPSFO Meetup Group
 
PPTX
NGINX: Back to Basics – APCJ
NGINX, Inc.
 
PDF
Using NGINX as an Effective and Highly Available Content Cache
Kevin Jones
 
PPTX
Delivering High Performance Websites with NGINX
NGINX, Inc.
 
PPTX
What's New in NGINX Plus R7?
NGINX, Inc.
 
PPTX
Flawless Application Delivery with NGINX Plus
Peter Guagenti
 
PDF
NGINX: The Past, Present and Future of the Modern Web
Kevin Jones
 
PDF
ITB2017 - Nginx ppf intothebox_2017
Ortus Solutions, Corp
 
PDF
ITB2017 - Nginx Effective High Availability Content Caching
Ortus Solutions, Corp
 
PPTX
NGINX 101 - now with more Docker
sarahnovotny
 
PPTX
NGINX 101 - now with more Docker
Sarah Novotny
 
PDF
Load Balancing with Nginx
Marian Marinov
 
PPTX
3 Ways to Automate App Deployments with NGINX
NGINX, Inc.
 
PDF
Scalable Architecture 101
ConFoo
 
PDF
How to Get Started With NGINX
NGINX, Inc.
 
PDF
Complete-NGINX-Cookbook-2019.pdf
TomaszWojciechowski22
 
PPTX
Drupal 8 and NGINX
NGINX, Inc.
 
KEY
Nginx - Tips and Tricks.
Harish S
 
Load Balancing Container with Nginx
Kumar Mayank
 
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
Ortus Solutions, Corp
 
What is Nginx and Why You Should to Use it with Wordpress Hosting
WPSFO Meetup Group
 
NGINX: Back to Basics – APCJ
NGINX, Inc.
 
Using NGINX as an Effective and Highly Available Content Cache
Kevin Jones
 
Delivering High Performance Websites with NGINX
NGINX, Inc.
 
What's New in NGINX Plus R7?
NGINX, Inc.
 
Flawless Application Delivery with NGINX Plus
Peter Guagenti
 
NGINX: The Past, Present and Future of the Modern Web
Kevin Jones
 
ITB2017 - Nginx ppf intothebox_2017
Ortus Solutions, Corp
 
ITB2017 - Nginx Effective High Availability Content Caching
Ortus Solutions, Corp
 
NGINX 101 - now with more Docker
sarahnovotny
 
NGINX 101 - now with more Docker
Sarah Novotny
 
Load Balancing with Nginx
Marian Marinov
 
3 Ways to Automate App Deployments with NGINX
NGINX, Inc.
 
Scalable Architecture 101
ConFoo
 
How to Get Started With NGINX
NGINX, Inc.
 
Complete-NGINX-Cookbook-2019.pdf
TomaszWojciechowski22
 
Drupal 8 and NGINX
NGINX, Inc.
 
Nginx - Tips and Tricks.
Harish S
 
Ad

More from NGINX, Inc. (20)

PDF
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
NGINX, Inc.
 
PDF
【NGINXセミナー】 NGINXのWAFとは?その使い方と設定方法 解説セミナー
NGINX, Inc.
 
PDF
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
NGINX, Inc.
 
PPTX
Get Hands-On with NGINX and QUIC+HTTP/3
NGINX, Inc.
 
PPTX
Managing Kubernetes Cost and Performance with NGINX & Kubecost
NGINX, Inc.
 
PDF
Manage Microservices Chaos and Complexity with Observability
NGINX, Inc.
 
PDF
Accelerate Microservices Deployments with Automation
NGINX, Inc.
 
PDF
Unit 2: Microservices Secrets Management 101
NGINX, Inc.
 
PDF
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
NGINX, Inc.
 
PDF
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
NGINX, Inc.
 
PDF
Easily View, Manage, and Scale Your App Security with F5 NGINX
NGINX, Inc.
 
PDF
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
NGINX, Inc.
 
PDF
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
NGINX, Inc.
 
PPTX
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
NGINX, Inc.
 
PPTX
Protecting Apps from Hacks in Kubernetes with NGINX
NGINX, Inc.
 
PPTX
NGINX Kubernetes API
NGINX, Inc.
 
PPTX
Successfully Implement Your API Strategy with NGINX
NGINX, Inc.
 
PPTX
Installing and Configuring NGINX Open Source
NGINX, Inc.
 
PPTX
Shift Left for More Secure Apps with F5 NGINX
NGINX, Inc.
 
PPTX
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
NGINX, Inc.
 
【NGINXセミナー】 Ingressを使ってマイクロサービスの運用を楽にする方法
NGINX, Inc.
 
【NGINXセミナー】 NGINXのWAFとは?その使い方と設定方法 解説セミナー
NGINX, Inc.
 
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
NGINX, Inc.
 
Get Hands-On with NGINX and QUIC+HTTP/3
NGINX, Inc.
 
Managing Kubernetes Cost and Performance with NGINX & Kubecost
NGINX, Inc.
 
Manage Microservices Chaos and Complexity with Observability
NGINX, Inc.
 
Accelerate Microservices Deployments with Automation
NGINX, Inc.
 
Unit 2: Microservices Secrets Management 101
NGINX, Inc.
 
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
NGINX, Inc.
 
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
NGINX, Inc.
 
Easily View, Manage, and Scale Your App Security with F5 NGINX
NGINX, Inc.
 
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
NGINX, Inc.
 
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
NGINX, Inc.
 
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
NGINX, Inc.
 
Protecting Apps from Hacks in Kubernetes with NGINX
NGINX, Inc.
 
NGINX Kubernetes API
NGINX, Inc.
 
Successfully Implement Your API Strategy with NGINX
NGINX, Inc.
 
Installing and Configuring NGINX Open Source
NGINX, Inc.
 
Shift Left for More Secure Apps with F5 NGINX
NGINX, Inc.
 
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
NGINX, Inc.
 
Ad

Recently uploaded (20)

PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Biography of Daniel Podor.pdf
Daniel Podor
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 

Load Balancing and Scaling with NGINX

  • 1. Load Balancing and Scaling with NGINX Introduced by Andrew Alexeev Presented by Owen Garrett Nginx, Inc.
  • 2. About this webinar When one server just isn’t enough, how can you scale out? In this webinar, you'll learn how to build out the capacity of your website. You'll see a variety of scalability approaches and some of the advanced capabilities of NGINX Plus.
  • 4. What is NGINX? Internet Proxy Caching, Load Balancing… HTTP traffic N Web Server Serve content from disk Application Server FastCGI, uWSGI, Passenger… Application Acceleration SSL and SPDY termination Performance Monitoring High Availability Advanced Features: Bandwidth Management Content-based Routing Request Manipulation Response Rewriting Authentication Video Delivery Mail Proxy GeoLocation
  • 6. 22% Top 1 million websites 37% Top 1,000 websites
  • 7. NGINX and NGINX Plus NGINX F/OSS nginx.org 3rd party modules Large community of >100 modules
  • 8. NGINX and NGINX Plus NGINX F/OSS nginx.org 3rd party modules Large community of >100 modules NGINX Plus Advanced load balancing features Ease-of-management Commercial support
  • 10. Load-balancing Web Servers Internet N  Improved Application Availability  Management  Increased Capacity  Advanced techniques e.g. A|B testing Why?  DNS Round Robin  Hardware L4 load balancer  Software Reverse Proxy LB  Cloud solution How?
  • 12. Three Load Balancing case studies Basic Load Balancing with NGINX When you need more control Advanced techniques 1 2 3
  • 13. 1. Basic Load Balancing • Simple scalability – All servers have same applications/services – Load-balancer extracts optimal performance
  • 14. Basic load balancing server { listen 80; location / { proxy_pass http://backend; } } upstream backend { zone backend 64k; server webserver1:80; server webserver2:80; server webserver3:80; server webserver4:80; }
  • 15. Basic load balancing • Use logging to debug: “$upstream_addr” log_format combined2 '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$upstream_addr"'; 192.168.56.1 - - [09/Mar/2014:23:08:56 +0000] "GET / HTTP/1.1" 200 30 "127.0.1.1:80" 192.168.56.1 - - [09/Mar/2014:23:08:56 +0000] "GET /favicon.ico HTTP/1.1" 200 30 "127.0.1.2:80" 192.168.56.1 - - [09/Mar/2014:23:08:57 +0000] "GET / HTTP/1.1" 200 30 "127.0.1.3:80" 192.168.56.1 - - [09/Mar/2014:23:08:57 +0000] "GET /favicon.ico HTTP/1.1" 200 30 "127.0.1.4:80" 192.168.56.1 - - [09/Mar/2014:23:08:57 +0000] "GET / HTTP/1.1" 200 30 "127.0.1.1:80" 192.168.56.1 - - [09/Mar/2014:23:08:57 +0000] "GET /favicon.ico HTTP/1.1" 200 30 "127.0.1.2:80" 192.168.56.1 - - [09/Mar/2014:23:08:58 +0000] "GET / HTTP/1.1" 200 30 "127.0.1.3:80" 192.168.56.1 - - [09/Mar/2014:23:08:58 +0000] "GET /favicon.ico HTTP/1.1" 200 30 "127.0.1.4:80"
  • 16. Basic Load Balancing • Round-robin is the default – Suitable for consistent pages • Least Connections – Suitable for varying pages • IP Hash – Fixed mapping, basic session persistence upstream backend { server webserver1:80; server webserver2:80; } upstream backend { least_conn; server webserver1:80; server webserver2:80; } upstream backend { ip_hash; server webserver1:80; server webserver2:80; }
  • 17. Managing the Upstream Group • Direct config editing: – nginx –s reload – upstream.conf file: upstream backend { server webserver1:80; server webserver2:80; server webserver3:80; server webserver4:80; } • On-the-fly Reconfiguration [NGINX Plus only] $ curl 'http://localhost/upstream_conf?upstream=backend&id=3&down=1'
  • 18. 2. When you need more control… • In many scenarios, you want more control over where traffic is routed to: – Primary and secondary servers (aka master/slave) – Transaction state is accumulated on one server
  • 19. ‘Master’ and ‘Slave’ servers • Wordpress admin traffic (e.g. image uploads) Internet N ‘Master’ ‘Slave’ Copy image uploads from master to slave
  • 20. ‘Master’ and ‘Slave’ servers • Wordpress admin traffic (e.g. image uploads) N server { listen 80; location ~ ^/(wp-admin|wp-login) { proxy_pass http://wpadmin; } } upstream wpadmin { server server1:80; server server2:80 backup; } ‘Master’ ‘Slave’
  • 21. Session Persistence [NGINX Plus only] • For when transaction state is accumulated on one server – Shopping carts – Advanced interactions – Non-RESTful Applications • NGINX Plus offers two methods: – sticky cookie – sticky route “Session persistence also helps performance”
  • 22. Advanced Techniques • You can control load-balancing programmatically – A|B Testing – Migration between applications
  • 23. A|B Testing Internet N ‘backends’ upstream group Test server 95% 5% Partition traffic. Send 5% to new application instance
  • 24. A|B Testing split_clients "${remote_addr}AAA" $servers { 95% backends; 5% 192.168.56.1:80; } server { listen 80; location / { proxy_pass http://$servers; } }
  • 25. Application Migration Internet N ‘backendsA’ upstream group ‘backendsB’ upstream group Create new generation of application Migrate users from old to new Preserve sessions, no interruptions
  • 26. Application Migration map $cookie_group $group { ~(?P<value>.+)$ $value; default backendB; # The default upstream group } server { listen 80; location / { add_header Set-Cookie "group=$group; path=/" proxy_pass http://$group; } }
  • 27. Three Load Balancing case studies Basic Load Balancing with NGINX When you need more control Advanced techniques 1 2 3
  • 28. Closing thoughts • 37% of the busiest websites use NGINX • Check out the load-balancing articles on nginx.com/blog • Future webinars: nginx.com/webinars Try NGINX F/OSS (nginx.org) or NGINX Plus (nginx.com)

Editor's Notes

  • #3: Hook. Scaling a wordpress site… but principles can be applied to any web-based service
  • #9: As we go through this presentation, we’ll highlight some of the new features that are specific to nginx plus
  • #11: Hardware load balancer – L4 (or may be software) Partial TCP stack DSR, connection mirroring, failover very high performance (packets per second, syn cookies,…) example: F5 fasthttp (software). Warnings e.g. out of order packets most moving to a software reverse proxy approach Reverse proxy Full TCP stack
  • #15: Which discipline should I use? Round robin is simple, but sometimes has odd side effects Least connections is very effective at smoothing out loads IP Hash gives a simple session persistence effect but may not distribute load effectively Demo: round robin with the config above will appear to fail because we will get responses from server1 and 3 only. This is because the client makes a ‘silent’ request for favicon.ico too.
  • #18: On-the-fly reconfig… need a ‘zone’ in the upstream group
  • #20: In wordpress, it’s common to synchronize filesystems in one direction
  • #22: Example – image editing application, shopping cart