Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Delivering High-Availability Web Services with...

NGINX Inc
November 20, 2014

Delivering High-Availability Web Services with NGINX Plus on AWS

Over 1/3 of websites running on Amazon Web Services (AWS) are delivered and accelerated using NGINX. Join Nginx and Amazon for this live webinar to learn how to get started with NGINX Plus on AWS and how to further increase performance and availability of large, dynamic, cloud-based applications integrating with critical AWS services.

NGINX Inc

November 20, 2014
Tweet

More Decks by NGINX Inc

Other Decks in Technology

Transcript

  1. Delivering High-Availability Web Services with NGINX Plus on AWS Owen

    Garrett Nginx, Inc. Scott Ward Amazon Web Services
  2. Introduc)ons  and  Agenda   •  Owen  Garre3   Head  of

     Products,  NGINX   •  Sco3  Ward   Solu)ons  Architect,  Amazon  Web  Services  
  3. 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.  
  4. Infrastructure Foundation Services Regions Availability Zones Storage (Object, Block and

    Archive) Networking Security & 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 Applications Virtual Desktops Data Workflows Usage Tracking Monitoring and Logs Compute (VMs, Auto-scaling and Load Balancing) CDN and Points of Presence Collaboration and Sharing
  5. 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
  6. 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
  7. Amazon EC2 Container Service   Creates  and  manages  clusters  made

     up  of  Docker  containers.  It  launches  and   terminates  the  containers  and  maintains  complete  informa)on  about  the   state  of  your  cluster     Automa)cally  schedules  containers  to  help  find  a  balance  between  your   resource  needs  and  availability  requirements     Using  EC2  Container  Service  you  can  simply  launch  &  manage  clusters  with   thousands  of  instances  and  schedule  tens  of  thousands  of  containers  across   mul)ple  Availability  Zones     Amazon  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  applica)ons  can  make  use  of  AWS  features  such  as  Elas)c  IP  addresses,   resource  tags,  and  Virtual  Private  Cloud  (VPC).   h3p://aws.amazon.com/ecs/    
  8. AWS Code Deploy   Deploys  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     Automa)cally  schedules  updates  across  mul)ple  Availability  Zones  in   order  to  maintain  high  availability  during  the  deployment       Applica)on  and  Deployment  groups  described  in  YAML-­‐forma3ed  files     Deployment  groups  iden)fy  EC2  instances  by  tags  &  can  also  reference   Auto  Scaling  Groups     Managed  via  AWS  Management  Console,  CLI  or  APIs     Can  be  used  in  conjunc)on  with  Chef  recipes  or  Puppet  scripts     Deploy  configura)on  from  a  variety  of  repositories  (S3,  GitHub,  etc)   h3ps://aws.amazon.com/codedeploy/    
  9. Amazon  web  applicaCon   reference  architecture   •  Route53  DNS

      •  Elas)c  Load  Balancer   •  Autoscaling  web  and   app  )ers   •  Ac)ve/standby   databases  
  10. Refactoring  the  architecture  with  NGINX   NGINX  provides  basic  

    load  balancing  for:   –  HTTP   –  FastCGI   –  uWSGI   –  SCGI   –  memcache  
  11. Go  further  with  NGINX  Plus   NGINX  F/OSS    

    Webserver   Accelera)ng  Proxy   Applica)on  Gateway   NGINX  Plus     Advanced  load  balancing  features    Health  checks,  Session  Persistence   Ease-­‐of-­‐management    Dynamic  Configura)on,  Extended  Status   Commercial  support  
  12. region region 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
  13. Relevant  NGINX  Plus  features   •  Content-­‐based  rou)ng   • 

    Request  Priori)za)on   •  Health  Checks   •  Session  Persistence   •  PROXY  support   •  Dynamic  Reconfigura)on  (inc  DNS)   •  Extended  Status  
  14. Content-­‐based  Rou)ng   Full  control  over  request     rouCng

     for  mulCple     applicaCons     Single  front-­‐end  ELB  service     Mul)ple  front-­‐end  domains   Mul)ple  back-­‐end  applica)ons  
  15. Request  Priori)za)on   Internet Large  spike  of  traffic   risks

     overwhelming   upstream  servers     NGINX  Plus  limits  concurrent   connec)ons  to  upstream  servers   and  queues  addi)onal  traffic   Upstream  servers   protected  from   effects  of  traffic  spike   max_conns=150
  16. Health  Checks   SophisCcated,  app-­‐specific   health  checks    

    Detect  applica)on  failures   Orchestrate  upgrades  
  17. Session  Persistence   Per-­‐applicaCon  session     persistence  rules  

      Cookie-­‐inser)on,  rules-­‐based,   Learn  mode     Consistent-­‐hash  load  balancing  
  18. PROXY  protocol   Internet Amazon  ELB  (mulCple  availability  zones)  

    Load-­‐balances  TCP  with  PROXY  protocol   NGINX  proxies  WebSockets   and  terminates  SPDY  traffic   Allows  for  support  for  WebSocket  proxying     and  SPDY  termina)on  
  19. Dynamic  Reconfigura)on   Control  load  balancing  configura)on  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  configura)on   API Upstream_conf  API  gives  a   simple  HTTP  API  to  control   configura)on  
  20. Extended  Status   …  with  CloudWatch  integra)on   GET /status/connections/active

    17 GET /status/upstreams/ demoupstreams/0/server ”192.168.45.2:80" { checks: 15375, fails: 183, unhealthy: 165, last_passed: true } GET /status/upstreams/ demoupstreams/0/health_checks
  21. Amazon CloudWatch Default Amazon EC2 metrics CPU 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
  22. NGINX Metrics into Amazon CloudWatch status.html à CloudWatch Install Agent

    $ sudo yum install nginx-cw-agent $ sudo apt-get install nginx-cw-agent  
  23. NGINX Metrics into Amazon CloudWatch status.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  
  24. NGINX Metrics into Amazon CloudWatch status.html à CloudWatch Start Background

    Agent  Test  -­‐  $ /usr/bin/nginx-cw-agent.py –f start  All  in  -­‐  $ sudo service nginx-cw-agent start   View  Metrics  
  25. 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
  26. NGINX with Amazon CloudWatch Logs EC2   EC2   EC2

      EC2   EC2   EC2   Capture  logs  from  mul)ple  instances  in  one  place   CloudWatch
  27.   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…?  
  28. Check  out  the  NGINX  Plus     on  AWS  whitepaper

        Partner  Whitepapers:   h3p://aws.amazon.com/whitepapers/       h3p://d0.awssta)c.com/whitepapers/ AWS_NGINX_Plus-­‐whitepaper-­‐final_v4.pdf