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

Scaling in EC2

Scaling in EC2

Given at the Nashville PHP Users Group

Shawn Stratton

May 13, 2014
Tweet

More Decks by Shawn Stratton

Other Decks in Technology

Transcript

  1. WHY THE CLOUD? • Virtual infrastructure can be added quickly.

    • Control the costs. • Reduce the headaches.
  2. WHY AMAZON? • Maturity - Amazon was the first real

    player in this space. • Additional Services Provided - RDS, SES, SNS, SQS. • Entire Ecosystem.
  3. WHAT’S DIFFERENT ABOUT THE CLOUD? • Instances are NOT servers,

    they behave differently. • You’re bound by the providers SLA (Service Level Agreement). • You don’t have as many options.
  4. THE TWO FACES OF SCALING V e r t i

    c a l H o r i z o n t a l
  5. VERTICAL SCALING • Pros • Simple - No change in

    Code or Maintenance. • Cost Effective to a point. ! • Cons • Cutover is painful - to a point. • Limit to how far you can scale.
  6. HORIZONTAL SCALING • Pros • Can scale up/down without downtime.

    • Smaller increments in capacity. ! • Cons • Code and Maintenance complexity.
  7. LET’S WALK THROUGH SOME ARCHITECTURES US East 1A EC2 Instance

    Elastic IP Internet Static Assets S3 RDS
  8. INTRODUCING AUTO SCALING GROUPS • Automated scaling in the cloud!

    • Generally based on Cloud Watch Metrics • Self Healing based on Health Tests • Scales On: • CPU • Network • Disk Usage • Load Balancer Metrics
  9. GROUPS, LAUNCH CONFIGS, POLICIES, OH MY Auto Scaling Group CPU

    Up Policy CPU Down Policy Subnets Desired Size Max / Min Health Check Launch Configuration Instance Type Security Groups User Data (Init Scripts) Amazon Machine Image (AMI) Instances
  10. END GAME Internet Content Delivery Network (CloudFront, Akamai, etc) Elastic

    Load Balancer Elastic Load Balancer Application Servers Static Servers Database Servers Utility Servers Master Database Cron CMS / App Admin
  11. ELASTIC LOAD BALANCERS • Supports HTTP, HTTPS, TCP, SSL and

    “Custom” protocols. • Integrates with Auto Scaling Groups. • Simple Configuration. • Can be created to be Internal to a VPC only. • Can only be used as a CNAME or Route 53 Alias as IP addresses change.
  12. HAPROXY • Lightweight HTTP and TCP proxy/load balancer. • Simple

    configuration, can pre-configure a
 class of servers. • Supports: • Round Robin, Least Connections, URI & URL, param designation, HDR, 
 and RDP based balancing. • Configurable health checks and failover.
  13. • C like configuration language. • Extendable. • Supports: •

    Edge Side Includes. • Stale-while-revalidate. • Redirecting, Rewriting, and URL Mapping. VARNISH
  14. APACHE TRAFFIC SERVER • Apache like configuration. • Extendable via

    plugins. • Supports: • Edge Side Includes (via plugin). • Stale-while-revalidate (via plugin). • Redirects, Rewrites, and URL Mapping.
  15. PUPPET • Ruby based. • Declarative format. • Uses Ruby

    templates. • Has orchestration tier - mcollective. • Large Open Source Community. • Puppet Forge.
  16. CHEF • Ruby based. • Declarative recipes, little more programatic.

    • Uses Ruby templates. • Has orchestration tier in Enterprise • Large Open Source Community. • Knife.
  17. SALT • Python based. • Declarative format. • Started as

    an orchestration system. • Large Open Source Community.
  18. AMAZON OPSWORKS • Amazon service to manage “layers” of applications.

    • Based on Chef, adds AWS control. • Supports AutoScaling Groups. • Well documented in the Amazon Documentation.
  19. USING THE API • Can write your own API clients

    in any language you chose. • Restful and SOAP API. • Amazon believes in “Dog Fooding”. • Popular SDK’s out for many languages: • PHP (includes Zend Framework 2 integration for v2) • Java • Python • Ruby • Node.js • .NET • Android • iOS
  20. CLOUD FORMATION • Uses JSON templates to build out infrastructure.

    • Can describe services to other services. ! • Supports:
 EC2 Instances & Security Groups, EBS Volumes, ELB, Elastic IPs, Auto Scaling Groups & Policies, RDS, DynamoDB, SimpleDB, SQS, SNS, Elastic Beanstalk, ElasticCache, CloudWatch alarms, CloudFront, S3, Identity & Access Management, Route 53 record management, VPC configuration including Subnets, Gateways, Route Tables, and ACLS.
  21. THIRD PARTY SOLUTIONS - RIGHTSCALE • Supports multiple vendors. •

    Uses Templates & Right Scale images. • Basically replaces Amazon Console and Amazon specific services.
  22. THIRD PARTY SOLUTIONS - OPEN SOURCE ! • Open Source.

    • Also available as SaaS via Scalr.com • Supports multiple cloud vendors. • GUI driven configuration. ! ! • Open Source. • Amazon specific. • Multi-Region Capable. • Uses Amazon concepts natively. Asgard Scalr
  23. PACKER.IO • Creates images - AMI and others. • Uses

    JSON build file. • Supports multiple builders - Puppet, Chef, Salt.
  24. AMINATOR • Only builds AMI. • Netflix backed. • Installs

    Packages, doesn’t necessary “Build”.
  25. POPULAR SERVICES NOT RECOMMENDED! • Cacti. • Munin. • Ganglia.

    • Nagios/Icinga. ! ! These require configuration files to be altered for each machine. 
 ! ! !
  26. CLOUD WATCH • Part of Management Console. • Stats available

    via API. • Default interval of 5 minutes, 
 can be upgraded. • Can store custom metrics. • Data used by Auto Scaling Groups 
 & Cloud Formation.
  27. COLLECTD & GRAPHITE • Near real time stats. • Custom

    retention periods. • Various front-ends. • Infinite way to configure graphs. • No need to preconfigure stats,
 just send and it will record.
  28. STACKDRIVER • Attempts to be near real time. • Easy

    to configure & administer. • Fairly cheap considering alternatives. • Supports custom metrics.
  29. HOW DO THESE LOOK IN PRODUCTION Virtual Private Cloud Availability

    Zone x2 (this is duplicated across us-east-1c and us-east-1d) us-east AWS Production Layout Diagram vat-elb ext-dws static Akamai vat-ats vat-php vat-python int-db ext-db int-solr ext-solr int-dws ext-dws ext-solr static ext-ats Internet Akamai / Internet ext-ats vat-ats haproxy ext-dws haproxy ext-db ext-solr haproxy int-dws haproxy int-db int-solr haproxy vat-python haproxy int-ats vat-php haproxy int-memcache Legend Caching Server Proxy / LB Application Server Data Source