SlideShare ist ein Scribd-Unternehmen logo
1 von 30
NGINX High Availability 
and Monitoring 
Introduced by Andrew Alexeev 
Presented by Owen Garrett 
Nginx, Inc.
About this webinar 
No one likes a broken website. Learn about some of the techniques that NGINX 
users employ to ensure that server failures are detected and worked around, so that 
you too can build large-scale, highly-available web services.
The cost of downtime
The causes of downtime 
“ Through 2015, 80% of outages impacting mission-critical 
services will be caused by people and process 
issues, and more than 50% of those outages will be 
caused by change/configuration/release integration 
and hand-off issues. ” 
Configuration Management for Virtual and Cloud 
Infrastructures 
Ronni J. Colville and George Spafford, Gartner 
Hardware failures, disasters 
People and Process
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
IMPROVING AVAILABILITY WITH NGINX
Quick review of load balancing 
server { 
listen 80; 
location / { 
proxy_pass http://backend; 
} 
} 
upstream backend { 
server webserver1:80; 
server webserver2:80; 
server webserver3:80; 
server webserver4:80; 
} 
Internet 
N
Three NGINX Techniques for High Availability 
NGINX: Basic Error Checks 
NGINX Plus: Advanced Health Checks 
Live software upgrades 
1 
2 
3
1. Basic Error Checks 
• Monitor transactions as they happen 
– Retry transactions that ‘fail’ where possible 
– Mark failed servers as dead
Basic Error Checks 
server { 
listen 80; 
location / { 
proxy_pass http://backend; 
proxy_next_upstream error timeout; # http_503..., off 
} 
} 
upstream backend { 
server webserver1:80 max_fails=1 fail_timeout=10s; 
server webserver2:80 max_fails=1 fail_timeout=10s; 
server webserver3:80 max_fails=1 fail_timeout=10s; 
server webserver4:80 max_fails=1 fail_timeout=10s; 
}
More sophisticated retries 
server { 
listen 80; 
location / { 
# On error/timeout, try the upstream group one more time 
error_page 502 504 = @fallback; 
proxy_pass http://backend; 
proxy_next_upstream off; 
} 
location @fallback { 
proxy_pass http://backend; 
proxy_next_upstream off; 
} 
}
2. Advanced Health Checks 
• “Synthetic Transactions” 
– Probes server health 
– Complex, custom tests are possible 
– Available in NGINX Plus
Advanced Health Checks 
server { 
listen 80; 
location / { 
proxy_pass http://backend; 
health_check; 
} 
} 
upstream backend { 
zone backend 64k; 
server webserver1:80; 
server webserver2:80; 
server webserver3:80; 
server webserver4:80; 
} 
health_check: 
interval = period between checks 
fails = failure count before dead 
passes = pass count before alive 
uri = custom URI 
Default: 
5 seconds, 1 fail, 1 pass, uri = /
Advanced usage 
server { 
listen 80; 
location / { 
proxy_pass http://backend; 
health_check uri=/test.php match=statusok; 
proxy_set_header Host www.foo.com; 
} 
} 
match statusok { 
# Used for /test.php health check 
status 200; 
header Content-Type = text/html; 
body ~ "Server[0-9]+ is alive"; 
} 
Health checks inherit all 
parameters from location 
block. 
match blocks define the 
success criteria for a 
health check
Edge cases – variables in configuration 
server { 
location / { 
proxy_pass http://backend; 
health_check; 
proxy_set_header Host $host; 
} 
} 
This may not work as expected. 
Remember – the health_check 
tests run in the context of the 
enclosing location.
Edge cases – variables in configuration 
server { 
location / { 
proxy_pass http://backend; 
health_check; 
proxy_set_header Host $host; 
} 
} 
server { 
location /internal-check { 
internal; 
proxy_pass http://backend; 
health_check; 
proxy_set_header Host www.foo.com; 
} 
} 
This may not work as expected. 
Remember – the health_check 
tests run in the context of the 
enclosing location. 
This is the common alternative. 
Use a custom URI for the location. 
Tag the location as internal. 
Set headers manually. 
Useful for authentication.
Examples of using health checks 
• Verify that pages 
don’t contain errors 
• Run internal tests (e.g. test.php => DB connect) 
• Managed removal of servers 
$ touch $DOCROOT/isactive.txt
Advantages of ‘Health Checks’ 
• Run tests asynchronously (find errors faster) 
• Custom tests (not related to ‘real’ traffic) 
• More flexibility to specify success/error
MORE NGINX PLUS FEATURES…
Slow start 
• When basic error checks and advanced health 
checks recover: 
upstream backends { 
zone backends 64k; 
server webserver1 slow_start=30s; 
}
NGINX Plus status monitoring 
http://demo.nginx.com/ and http://demo.nginx.com/status 
Total data and connections 
Current data and conns. 
Split per ‘server zone’ 
Cache statistics 
Upstream statistics: 
Traffic 
Health and Error status 
(web) (JSON)
3. Live software upgrades 
• Upgrade your NGINX binary on-the-fly 
– No downtime 
– No dropped connections
No downtime – ever! 
• Reload configuration with SIGHUP 
# nginx –s reload 
• Re-exec binary with copy-and-signal 
http://nginx.org/en/docs/control.html#upgrade 
NGINX parent process 
NGINX workers 
NGINX workers 
NGINX workers 
NGINX workers
In summary... 
NGINX F/OSS: 
Basic Error checks and retry logic On-the-fly upgrades 
NGINX Plus: 
Advanced health checks + slow start Extended status monitoring 
Compared to other load balancers and ADCs, NGINX Plus is uniquely well-suited 
to a devops-driven environment.
Closing thoughts 
• 37% of the busiest websites use NGINX 
– In most situations, it’s a drop-in extension 
• Check out the blogs on nginx.com 
• Future webinars: nginx.com/webinars 
Try NGINX F/OSS (nginx.org) or NGINX Plus (nginx.com)

Weitere ähnliche Inhalte

Andere mochten auch

Naxsi, an open source WAF for Nginx
Naxsi, an open source WAF  for NginxNaxsi, an open source WAF  for Nginx
Naxsi, an open source WAF for Nginx
Positive Hack Days
 
Load Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXLoad Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINX
NGINX, Inc.
 
Nginx - Tips and Tricks.
Nginx - Tips and Tricks.Nginx - Tips and Tricks.
Nginx - Tips and Tricks.
Harish S
 
Nginx performance monitoring with Dynatrace
Nginx performance monitoring with DynatraceNginx performance monitoring with Dynatrace
Nginx performance monitoring with Dynatrace
Harald Zeitlhofer
 
Huong dan cai dat hadoop
Huong dan cai dat hadoopHuong dan cai dat hadoop
Huong dan cai dat hadoop
Quỳnh Phan
 

Andere mochten auch (19)

The 3 Models in the NGINX Microservices Reference Architecture
The 3 Models in the NGINX Microservices Reference ArchitectureThe 3 Models in the NGINX Microservices Reference Architecture
The 3 Models in the NGINX Microservices Reference Architecture
 
NGINX High-performance Caching
NGINX High-performance CachingNGINX High-performance Caching
NGINX High-performance Caching
 
Naxsi, an open source WAF for Nginx
Naxsi, an open source WAF  for NginxNaxsi, an open source WAF  for Nginx
Naxsi, an open source WAF for Nginx
 
Lcu14 Lightning Talk- NGINX
Lcu14 Lightning Talk- NGINXLcu14 Lightning Talk- NGINX
Lcu14 Lightning Talk- NGINX
 
Monitoring Highly Dynamic and Distributed Systems with NGINX Amplify
Monitoring Highly Dynamic and Distributed Systems with NGINX AmplifyMonitoring Highly Dynamic and Distributed Systems with NGINX Amplify
Monitoring Highly Dynamic and Distributed Systems with NGINX Amplify
 
Nginx in production
Nginx in productionNginx in production
Nginx in production
 
Load Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXLoad Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINX
 
Nginx - Tips and Tricks.
Nginx - Tips and Tricks.Nginx - Tips and Tricks.
Nginx - Tips and Tricks.
 
Nginx+ Naxsi
Nginx+ NaxsiNginx+ Naxsi
Nginx+ Naxsi
 
Procesy konwersji a zarządzanie produktem na przykładzie Alegratka.pl
 Procesy konwersji a zarządzanie produktem na przykładzie Alegratka.pl Procesy konwersji a zarządzanie produktem na przykładzie Alegratka.pl
Procesy konwersji a zarządzanie produktem na przykładzie Alegratka.pl
 
Time-Series Monitoring Graphs with D3 & Rickshaw
Time-Series Monitoring Graphs with D3 & RickshawTime-Series Monitoring Graphs with D3 & Rickshaw
Time-Series Monitoring Graphs with D3 & Rickshaw
 
Nginx performance monitoring with Dynatrace
Nginx performance monitoring with DynatraceNginx performance monitoring with Dynatrace
Nginx performance monitoring with Dynatrace
 
Huong dan cai dat hadoop
Huong dan cai dat hadoopHuong dan cai dat hadoop
Huong dan cai dat hadoop
 
HTTP/2: Ask Me Anything
HTTP/2: Ask Me AnythingHTTP/2: Ask Me Anything
HTTP/2: Ask Me Anything
 
Monitoring NGINX (plus): key metrics and how-to
Monitoring NGINX (plus): key metrics and how-toMonitoring NGINX (plus): key metrics and how-to
Monitoring NGINX (plus): key metrics and how-to
 
Global Varnish Cluster with GeoDNS
Global Varnish Cluster with GeoDNSGlobal Varnish Cluster with GeoDNS
Global Varnish Cluster with GeoDNS
 
WordPress + NGINX Best Practices with EasyEngine
WordPress + NGINX Best Practices with EasyEngineWordPress + NGINX Best Practices with EasyEngine
WordPress + NGINX Best Practices with EasyEngine
 
Devops training in Hyderabad
Devops training in HyderabadDevops training in Hyderabad
Devops training in Hyderabad
 
What's New in HTTP/2
What's New in HTTP/2What's New in HTTP/2
What's New in HTTP/2
 

Mehr von NGINX, Inc.

How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
How to Avoid the Top 5 NGINX Configuration Mistakes.pptxHow to Avoid the Top 5 NGINX Configuration Mistakes.pptx
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
NGINX, Inc.
 

Mehr von NGINX, Inc. (20)

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

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

NGINX High Availability and Monitoring

  • 1. NGINX High Availability and Monitoring Introduced by Andrew Alexeev Presented by Owen Garrett Nginx, Inc.
  • 2. About this webinar No one likes a broken website. Learn about some of the techniques that NGINX users employ to ensure that server failures are detected and worked around, so that you too can build large-scale, highly-available web services.
  • 3. The cost of downtime
  • 4. The causes of downtime “ Through 2015, 80% of outages impacting mission-critical services will be caused by people and process issues, and more than 50% of those outages will be caused by change/configuration/release integration and hand-off issues. ” Configuration Management for Virtual and Cloud Infrastructures Ronni J. Colville and George Spafford, Gartner Hardware failures, disasters People and Process
  • 6. 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
  • 8. 22% Top 1 million websites 37% Top 1,000 websites
  • 9. NGINX and NGINX Plus NGINX F/OSS nginx.org 3rd party modules Large community of >100 modules
  • 10. 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
  • 12. Quick review of load balancing server { listen 80; location / { proxy_pass http://backend; } } upstream backend { server webserver1:80; server webserver2:80; server webserver3:80; server webserver4:80; } Internet N
  • 13. Three NGINX Techniques for High Availability NGINX: Basic Error Checks NGINX Plus: Advanced Health Checks Live software upgrades 1 2 3
  • 14. 1. Basic Error Checks • Monitor transactions as they happen – Retry transactions that ‘fail’ where possible – Mark failed servers as dead
  • 15. Basic Error Checks server { listen 80; location / { proxy_pass http://backend; proxy_next_upstream error timeout; # http_503..., off } } upstream backend { server webserver1:80 max_fails=1 fail_timeout=10s; server webserver2:80 max_fails=1 fail_timeout=10s; server webserver3:80 max_fails=1 fail_timeout=10s; server webserver4:80 max_fails=1 fail_timeout=10s; }
  • 16. More sophisticated retries server { listen 80; location / { # On error/timeout, try the upstream group one more time error_page 502 504 = @fallback; proxy_pass http://backend; proxy_next_upstream off; } location @fallback { proxy_pass http://backend; proxy_next_upstream off; } }
  • 17. 2. Advanced Health Checks • “Synthetic Transactions” – Probes server health – Complex, custom tests are possible – Available in NGINX Plus
  • 18. Advanced Health Checks server { listen 80; location / { proxy_pass http://backend; health_check; } } upstream backend { zone backend 64k; server webserver1:80; server webserver2:80; server webserver3:80; server webserver4:80; } health_check: interval = period between checks fails = failure count before dead passes = pass count before alive uri = custom URI Default: 5 seconds, 1 fail, 1 pass, uri = /
  • 19. Advanced usage server { listen 80; location / { proxy_pass http://backend; health_check uri=/test.php match=statusok; proxy_set_header Host www.foo.com; } } match statusok { # Used for /test.php health check status 200; header Content-Type = text/html; body ~ "Server[0-9]+ is alive"; } Health checks inherit all parameters from location block. match blocks define the success criteria for a health check
  • 20. Edge cases – variables in configuration server { location / { proxy_pass http://backend; health_check; proxy_set_header Host $host; } } This may not work as expected. Remember – the health_check tests run in the context of the enclosing location.
  • 21. Edge cases – variables in configuration server { location / { proxy_pass http://backend; health_check; proxy_set_header Host $host; } } server { location /internal-check { internal; proxy_pass http://backend; health_check; proxy_set_header Host www.foo.com; } } This may not work as expected. Remember – the health_check tests run in the context of the enclosing location. This is the common alternative. Use a custom URI for the location. Tag the location as internal. Set headers manually. Useful for authentication.
  • 22. Examples of using health checks • Verify that pages don’t contain errors • Run internal tests (e.g. test.php => DB connect) • Managed removal of servers $ touch $DOCROOT/isactive.txt
  • 23. Advantages of ‘Health Checks’ • Run tests asynchronously (find errors faster) • Custom tests (not related to ‘real’ traffic) • More flexibility to specify success/error
  • 24. MORE NGINX PLUS FEATURES…
  • 25. Slow start • When basic error checks and advanced health checks recover: upstream backends { zone backends 64k; server webserver1 slow_start=30s; }
  • 26. NGINX Plus status monitoring http://demo.nginx.com/ and http://demo.nginx.com/status Total data and connections Current data and conns. Split per ‘server zone’ Cache statistics Upstream statistics: Traffic Health and Error status (web) (JSON)
  • 27. 3. Live software upgrades • Upgrade your NGINX binary on-the-fly – No downtime – No dropped connections
  • 28. No downtime – ever! • Reload configuration with SIGHUP # nginx –s reload • Re-exec binary with copy-and-signal http://nginx.org/en/docs/control.html#upgrade NGINX parent process NGINX workers NGINX workers NGINX workers NGINX workers
  • 29. In summary... NGINX F/OSS: Basic Error checks and retry logic On-the-fly upgrades NGINX Plus: Advanced health checks + slow start Extended status monitoring Compared to other load balancers and ADCs, NGINX Plus is uniquely well-suited to a devops-driven environment.
  • 30. Closing thoughts • 37% of the busiest websites use NGINX – In most situations, it’s a drop-in extension • Check out the blogs on nginx.com • Future webinars: nginx.com/webinars Try NGINX F/OSS (nginx.org) or NGINX Plus (nginx.com)

Hinweis der Redaktion

  1. Story starts with a single guy, Igor Sysoev What was originally a tool for managing concurrency hos evolved into a Web Application Accelerator Not because of vision but user driven innovation
  2. http://www.networkworld.com/careers/2004/0105man.html http://www.evolven.com/blog/downtime-outages-and-failures-understanding-their-true-costs.html Cost of downtime: Reputation PPC ads Job losses £1m / hour downtime UK service example
  3. How do we reduce this 80%? We need infrastructure that works with our processes, is tightly integrated with our devops practices, that we can work with rather than battle against. http://www.evolven.com/blog/downtime-outages-and-failures-understanding-their-true-costs.html Misconfigurations Have Major Impact on Performance The IT Process Institute's Visible Ops Handbook reports that "80% of unplanned outages are due to ill-planned changes made by administrators ("operations staff") or developers." (Visible Ops). Getting to the bottom of the matter, the Enterprise Management Association reports that 60% of availability and performance errors are the result of misconfigurations. The little changes that are implemented to the environment and system configuration parameters all the time. A recent Gartner study projected that "Through 2015, 80% of outages impacting mission-critical services will be caused by people and process issues, and more than 50% of those outages will be caused by change/configuration/release integration and hand-off issues." (Ronni J. Colville and George Spafford Configuration Management for Virtual and Cloud Infrastructures) Manual configuration errors can cost companies up to $72,000 per hour in Web application downtime. While application maintenance costs are increasing at a rate of 20% annually, 35% of those polled said at least one-quarter of their downtime was caused by configuration errors. (How much will you spend on application downtime this year?) - See more at: http://www.evolven.com/blog/downtime-outages-and-failures-understanding-their-true-costs.html#sthash.QvXJhaCC.dpuf
  4. As we go through this presentation, we’ll highlight some of the new features that are specific to nginx plus
  5. proxy_next_upstream error timeout is default server max_fails=1 fail_timeout=10s is default
  6. 502 – bad gateway 504 - timeout
  7. 5s 1 fail 1 pass URI = /
  8. Remember that a significant proportion of failures occur because of errors in process. NGINX Plus is more flexible and can be more easily accomodated by your standard devops process.