delivering high-availability web services with nginx plus on aws

45
Delivering High-Availability Web Services with NGINX Plus on AWS Owen Garrett Nginx, Inc. Scott Ward Amazon Web Services

Upload: nginx-inc

Post on 13-Jul-2015

770 views

Category:

Technology


8 download

TRANSCRIPT

Page 1: Delivering High-Availability Web Services with NGINX Plus on AWS

Delivering High-Availability Web Services with NGINX Plus on AWS

Owen Garrett

Nginx, Inc.

Scott Ward

Amazon Web Services

Page 2: Delivering High-Availability Web Services with NGINX Plus on AWS

Introductions and Agenda

• Owen GarrettHead of Products, NGINX

• Scott WardSolutions Architect, Amazon Web Services

Page 3: Delivering High-Availability Web Services with NGINX Plus on AWS

Introducing Amazon Web Services

Page 4: Delivering High-Availability Web Services with NGINX Plus on AWS

A broad and deep platform that helps customers

build sophisticated, scalable applications

© 2014 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.

Page 5: Delivering High-Availability Web Services with NGINX Plus on AWS

A Culture of Innovation: Experiment Often & Fail Without

Risk

Page 6: Delivering High-Availability Web Services with NGINX Plus on AWS

Who is using AWS and what are

they using it for?

Page 7: Delivering High-Availability Web Services with NGINX Plus on AWS

Startups on AWS

http://aws.amazon.com/solutions/case-studies/

Page 8: Delivering High-Availability Web Services with NGINX Plus on AWS

Enterprises on AWS

http://aws.amazon.com/solutions/case-studies/

Page 9: Delivering High-Availability Web Services with NGINX Plus on AWS

Infrastructure

Foundation

Services

Regions Availability Zones

Storage(Object, Block and Archive)

NetworkingSecurity &

Access Control

Platform

Services

Databases

Relational

NoSQL

Caching

Analytics

Hadoop

Real-time

Data warehouse

App Services

Queuing

Orchestration

App streaming

Transcoding

Email

Search

Deployment & Management

Containers

Dev/ops Tools

Resource

Templates

Mobile Services

Identity

Sync

Mobile

Analytics

Notifications

Enterprise

ApplicationsVirtual Desktops

Data Workflows

Usage

Tracking

Monitoring

and Logs

Compute(VMs, Auto-scaling and Load Balancing)

CDN and Points of Presence

Collaboration and Sharing

Page 10: Delivering High-Availability Web Services with NGINX Plus on AWS

11 regions

28 availability

zones

52 edge locations

Infrastructure

Page 11: Delivering High-Availability Web Services with NGINX Plus on AWS

AWS Services Overview

Amazon EC2 – Virtual Servers & resizable compute capacity

Auto Scaling – Scale compute resources up and down

Elastic Load Balancing – Load balancer for compute instances

Amazon Elastic Block Storage (EBS) – Block storage for EC2

Page 12: Delivering High-Availability Web Services with NGINX Plus on AWS

AWS Service Overview

AWS Identity and Access Management – AWS Account Access Controls

Amazon Route 53 – Scalable Domain Name System

Amazon CloudWatch – Resource and Application Monitoring

Page 13: Delivering High-Availability Web Services with NGINX Plus on AWS

Breaking news - New services on AWS

Page 14: Delivering High-Availability Web Services with NGINX Plus on AWS

Amazon EC2 Container Service

Creates and manages clusters made up of Docker containers. It launches and terminates the containers and maintains complete information about the state of your clusterAutomatically schedules containers to help find a balance between your resource needs and availability requirementsUsing EC2 Container Service you can simply launch & manage clusters with thousands of instances and schedule tens of thousands of containers across multiple Availability ZonesAmazon EC2 Container Service launches your containers on your own EC2 instances, so that you do not share resources with other customers, places your clusters in a VPC, and allows you to use your own VPC security groups and network ACLs.Your applications can make use of AWS features such as Elastic IP addresses, resource tags, and Virtual Private Cloud (VPC).

http://aws.amazon.com/ecs/

Page 15: Delivering High-Availability Web Services with NGINX Plus on AWS

AWS Code DeployDeploys your released code to a "fleet" of EC2 instances

Accommodate fleets that range in size from one instance all the way up to tens of thousands of instances

Automatically schedules updates across multiple Availability Zones in order to maintain high availability during the deployment

Application and Deployment groups described in YAML-formatted files

Deployment groups identify EC2 instances by tags & can also reference Auto Scaling Groups

Managed via AWS Management Console, CLI or APIs

Can be used in conjunction with Chef recipes or Puppet scripts

Deploy configuration from a variety of repositories (S3, GitHub, etc)

https://aws.amazon.com/codedeploy/

Page 16: Delivering High-Availability Web Services with NGINX Plus on AWS

Successful projects use NGINX on AWS

Page 17: Delivering High-Availability Web Services with NGINX Plus on AWS

INTRODUCING NGINX AND NGINX PLUS

Page 18: Delivering High-Availability Web Services with NGINX Plus on AWS

Amazon web applicationreference architecture

• Route53 DNS

• Elastic Load Balancer

• Autoscaling web and app tiers

• Active/standby databases

Page 19: Delivering High-Availability Web Services with NGINX Plus on AWS

Refactoring the architecture with NGINX

NGINX provides basic load balancing for:

– HTTP

– FastCGI

– uWSGI

– SCGI

– memcache

Page 20: Delivering High-Availability Web Services with NGINX Plus on AWS

Go further with NGINX Plus

NGINX F/OSS

WebserverAccelerating ProxyApplication Gateway

NGINX Plus

Advanced load balancing featuresHealth checks, Session Persistence

Ease-of-managementDynamic Configuration, Extended Status

Commercial support

Page 21: Delivering High-Availability Web Services with NGINX Plus on AWS

regionregion

region

Elastic Load Balancer

Web App 1

NGINX Plus

AMI

Web App 2 Web App 3

Route53 hosted zone

Web App 1

NGINX Plus

AMI

Web App 2 Web App 3

Page 22: Delivering High-Availability Web Services with NGINX Plus on AWS

Relevant NGINX Plus features• Content-based routing• Request Prioritization• Health Checks• Session Persistence• PROXY support• Dynamic Reconfiguration (inc DNS)• Extended Status

Page 23: Delivering High-Availability Web Services with NGINX Plus on AWS

Content-based Routing

Full control over request routing for multiple applications

Single front-end ELB service

Multiple front-end domainsMultiple back-end applications

Page 24: Delivering High-Availability Web Services with NGINX Plus on AWS

Request Prioritization

Internet

Large spike of traffic risks overwhelming upstream servers

NGINX Plus limits concurrent connections to upstream servers

and queues additional traffic

Upstream servers protected from

effects of traffic spike

max_conns=150

Page 25: Delivering High-Availability Web Services with NGINX Plus on AWS

Health Checks

Sophisticated, app-specifichealth checks

Detect application failuresOrchestrate upgrades

Page 26: Delivering High-Availability Web Services with NGINX Plus on AWS

Session Persistence

Per-application session persistence rules

Cookie-insertion, rules-based,Learn mode

Consistent-hash load balancing

Page 27: Delivering High-Availability Web Services with NGINX Plus on AWS

PROXY protocol

Internet

Amazon ELB (multiple availability zones)Load-balances TCP with PROXY protocol

NGINX proxies WebSockets and terminates SPDY traffic

Allows for support for WebSocket proxyingand SPDY termination

Page 28: Delivering High-Availability Web Services with NGINX Plus on AWS

Dynamic Reconfiguration

Control load balancing configuration dynamically

http {

resolver 192.168.0.2;

upstream backends {

zone backends 64k;

server api.u.com resolve;

}

upstream_conf;

}

DNS

Changes in DNS can dynamically update NGINX Plus’ load balancing configuration API

Upstream_conf API gives a simple HTTP API to control configuration

Page 29: Delivering High-Availability Web Services with NGINX Plus on AWS

Extended Status

… with CloudWatch integration

GET /status/connections/active 17

GET

/status/upstreams/demoupstream

s/0/server

”192.168.45.2:80"

{

checks: 15375,

fails: 183,

unhealthy: 165,

last_passed: true

}

GET

/status/upstreams/demoupstream

s/0/health_checks

Page 30: Delivering High-Availability Web Services with NGINX Plus on AWS

Complementing Amazon ELB

Page 31: Delivering High-Availability Web Services with NGINX Plus on AWS

Monitoring with Cloudwatch

Know what is going on with your

environment at all times

Page 32: Delivering High-Availability Web Services with NGINX Plus on AWS

Amazon CloudWatch

Default Amazon EC2

metricsCPU Utilization (Percent)

Disk Reads (Bytes)

Disk Read Operations (Operations)

Disk Writes (Bytes)

Disk Write Operations (Operations)

Network In (Bytes)

Network Out (Bytes)

Status Check Failed (Count)

1 or 5 minute intervals

Page 33: Delivering High-Availability Web Services with NGINX Plus on AWS

NGINX Metrics into Amazon CloudWatchstatus.html CloudWatch

Install Agent$ sudo yum install nginx-cw-agent

$ sudo apt-get install nginx-cw-agent

Page 34: Delivering High-Availability Web Services with NGINX Plus on AWS

NGINX Metrics into Amazon CloudWatchstatus.html CloudWatch

Update Configuration$ /etc/nginx-cw-agent/nginx-cw-agent.ini

[source1]

name=exampleorg

url=http://example.org/status

[source2]

name=examplecom

url=http://example.com/status

http_user=testuser

http_pass=testpass

Page 35: Delivering High-Availability Web Services with NGINX Plus on AWS

NGINX Metrics into Amazon CloudWatchstatus.html CloudWatch

Start Background AgentTest - $ /usr/bin/nginx-cw-agent.py –f start

All in - $ sudo service nginx-cw-agent start

View Metrics

Page 36: Delivering High-Availability Web Services with NGINX Plus on AWS

NGINX with Amazon CloudWatch Logs

• Consolidate metrics and alarming for log files from 1 or many instances

• Define filters to parse content from your log files

• Measure and alarm on specific attributes

• Define retention period for your log files

EC2

CloudWatch

Page 37: Delivering High-Availability Web Services with NGINX Plus on AWS

NGINX with Amazon CloudWatch Logs

Filter

Alarm

Page 38: Delivering High-Availability Web Services with NGINX Plus on AWS

NGINX with Amazon CloudWatch Logs

EC2

EC2EC2

EC2 EC2

EC2

Capture logs from multiple instances in one place

CloudWatch

Page 39: Delivering High-Availability Web Services with NGINX Plus on AWS

NEXT STEPS

Page 40: Delivering High-Availability Web Services with NGINX Plus on AWS

Get started with NGINX Plus AMI

http://aws.amazon.com/marketplace

Page 41: Delivering High-Availability Web Services with NGINX Plus on AWS

Finding NGINX Plus on AWShttp://aws.amazon.com/marketplace - search for NGINX

Page 42: Delivering High-Availability Web Services with NGINX Plus on AWS
Page 43: Delivering High-Availability Web Services with NGINX Plus on AWS

ubuntu@ip-172-31-20-254:~$ /etc/init.d/nginx status

* nginx is running

ubuntu@ip-172-31-20-254:~$ cd /etc/nginx/conf.d

ubuntu@ip-172-31-20-254:~$ nginx –s reload

Is it running…?

Page 44: Delivering High-Availability Web Services with NGINX Plus on AWS

Check out the NGINX Plus on AWS whitepaper

Partner Whitepapers:http://aws.amazon.com/whitepapers/

http://d0.awsstatic.com/whitepapers/AWS_NGINX_Plus-whitepaper-final_v4.pdf

Page 45: Delivering High-Availability Web Services with NGINX Plus on AWS

THANK YOU