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

Mobile Scale AWS

41412a40b6ba18ba3e82a887a4f2e0de?s=47 Ben Whaley
August 11, 2014

Mobile Scale AWS

Presented at Intuit as a tech talk on running services at scale on AWS. Video recording (somewhat poor audio quality) available here: http://youtu.be/hTJZmud0uVM

41412a40b6ba18ba3e82a887a4f2e0de?s=128

Ben Whaley

August 11, 2014
Tweet

Transcript

  1. Mobile Scale Web Applications using Amazon Web Services! Ben Whaley

    @iAmTheWhaley!
  2. Mobile scale! 3.5-4 billion mobile phones! vs ~1.8 billion PCs!

  3. None
  4. Mobile scale! Weeks of product development, not months or years!

  5. Mobile scale! ~1.2 million apps each in the Apple App

    Store and Google Play!
  6. Mobile scale! 1-5 trillion photos taken in 2014 ! vs

     ~80  billion  in  1999  
  7. Mobile scale! Impact of Internet of Things still TBD!

  8. “Smartphones liberate the internet from the browser in the same

    way that the browser liberated it from the command line”! ! !! ! !!- Benedict Evans!
  9. Mature mobile platforms! •  Use the cloud to enable rich

    native apps! •  Blur the line between apps and the web! •  Hyperlocal via iBeacons & NFC! •  “Mobile” is no longer “smartphone”! – Car tech! – Watches! – TV! – Google glass!
  10. Mobile is powered by APIs
 
 
 (APIs live in

    the cloud)!
  11. None
  12. None
  13. None
  14. None
  15. Key Business Drivers! •  API-driven interfaces! •  Data pipelines for

    business analytics! •  Improved availability! •  Elasticity for ! – Cost savings! – Capacity on demand! •  Focus on core competencies!
  16. Designing for Mobile Scale, in Four Parts!

  17. Part I: Network!

  18. The Foundation! •  The first ubiquitous SDN! •  Create and

    configure via! –  Console! –  API! –  CloudFormation! •  Key features include:! –  Custom route tables! –  Public and private subnets! –  Security groups! –  Network ACLs! –  Native support for many AWS services! –  VPN Gateways! –  Intra-region peering! !
  19. Infrastructure VPC Subnet Design Public web Private Services Persistence 10.0.2.0/24

    10.0.1.0/24 10.0.0.0/24 10.0.12.0/24 10.0.11.0/24 10.0.10.0/24 10.0.22.0/24 10.0.21.0/24 10.0.20.0/24 10.0.32.0/24 10.0.31.0/24 10.0.30.0/24 Availability Zone A Availability Zone B Availability Zone C us-east-1 10.0.0.0/16 Infrastructure VPC Subnet Design Public web Private Services Persistence 10.0.2.0/24 10.0.1.0/24 10.0.0.0/24 10.0.12.0/24 10.0.11.0/24 10.0.10.0/24 10.0.22.0/24 10.0.21.0/24 10.0.20.0/24 10.0.32.0/24 10.0.31.0/24 10.0.30.0/24 Availability Zone A Availability Zone B Availability Zone C us-east-1 10.0.0.0/16
  20. None
  21. None
  22. None
  23. None
  24. us-east-1 10.0.0.0/16 Application A us-east-1 10.1.0.0/16 Application B Micronets!

  25. us-east-1 10.0.0.0/16 Development us-east-1 10.10.0.0/16 Test us-east-1 10.20.0.0/16 Staging us-east-1

    10.30.0.0/16 Production Environment Separation!
  26. us-east-1 10.0.0.0/16 Application A eu-west-1 10.10.0.0/16 Application A us-west-2 10.20.0.0/16

    Application A ap-southeast-1 10.30.0.0/16 Application A Cross-region VPCs! VPN Gateway! or! Direct Connect!
  27. •  Principle of Least Privilege realized! •  Use a private

    subnets when inbound connections are not required! •  Reduces overall Internet-facing footprint! •  Per application security groups! •  Allow access by group, not CIDR! •  Separate cross-subnet access using ACLs! VPC Security Benefits!
  28. •  Intra-zone: < 1ms! •  Intra-region: < 5ms! •  Between

    VPCs: < 5ms, with SSL +20-40ms! •  us-west-2 – us-east-1: ~100ms! •  us-east-1 – eu-west-1: ~100ms! •  us-east-1 – ap-southeast-1: ~250ms! Latency Considerations!
  29. Part II: Systems!

  30. “Construct a highly agile and highly available service from ephemeral

    and often broken components”! ! ! !! !- Adrian Cockcroft! ! ! “The simpler, the better. Complications lead to multiplicative chains of unanticipated effects.”! ! - Nassim Nicholas Taleb, Antifragile!
  31. AWS System Design! •  n+2 redundancy! n n+1 n+2

  32. AWS System Design! •  n+2 redundancy! •  Compute resources are

    ephemeral! n n+1 n+2 n+3 n+4 n+5
  33. AWS System Design! •  n+2 redundancy! •  Compute resources are

    ephemeral! •  Infrastructure captured as code! "Resources" : {! "Ec2Instance" : {! "Type" : "AWS::EC2::Instance", ! "Properties" : {! "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, "PV64" ]},! "KeyName" : { "Ref" : "KeyName" },! "InstanceType" : "m1.small",! "SecurityGroups" : [{ "Ref" : "Ec2SecurityGroup" }],! "BlockDeviceMappings" : [! {! "DeviceName" : "/dev/sdc",! "VirtualName" : "ephemeral0"! }! ]! }! },!
  34. AWS System Design! •  n+2 redundancy! •  Compute resources are

    ephemeral! •  Infrastructure captured as code! •  Minimalist operating system!
  35. AWS System Design! •  n+2 redundancy! •  Compute resources are

    ephemeral! •  Infrastructure captured as code! •  Minimalist operating system! •  Databases are multi-AZ w/ provisioned IOPS! •  Use read replicas when possible!
  36. AWS System Design! •  n+2 redundancy! •  Compute resources are

    ephemeral! •  Infrastructure captured as code! •  Minimalist operating system! •  Databases are multi-AZ w/ provisioned IOPS! •  Use read replicas when possible! •  Who needs internal DNS?!
  37. AWS System Design! •  n+2 redundancy! •  Compute resources are

    ephemeral! •  Infrastructure captured as code! •  Minimalist operating system! •  Databases are multi-AZ w/ provisioned IOPS! •  Use read replicas when possible! •  Who needs internal DNS?! •  Tag all the things!
  38. How baked should you be?! Config  managed  instances   Fully

     baked  AMI   Most  users  needs  
  39. •  Reserved instances! •  Choosing correct instance types:! •  Default

    to T2 for development, small web services! •  General purpose M3! •  C3 for heavy compute needs! •  R3 for memory intensive apps! •  Use autoscale groups with appropriate triggers and minimums! Cost Optimizations!
  40. Part III: Applications!

  41. •  Stateless processes! Cloud Native Application Design! Database App  Server

      App  Server  
  42. •  Stateless processes! •  Loose coupling among services! Cloud Native

    Application Design! Service  1   Service  2   Service  3   Queue   Queue  
  43. •  Stateless processes! •  Loose coupling among services! •  Deep

    instrumentation! Cloud Native Application Design!
  44. •  Stateless processes! •  Loose coupling among services! •  Deep

    instrumentation! •  Keep configuration in the environment! Cloud Native Application Design!
  45. •  Implementation is not complete until there are unit tests!

    Cloud Native Application Design!
  46. •  Stateless processes! •  Loose coupling among services! •  Deep

    instrumentation! •  Keep configuration in the environment! •  Implementation is not complete until there are unit tests! •  Open source by default! Cloud Native Application Design!
  47. Embracing AWS Services! •  SQS vs AMQP! •  RDS vs

    on-instance Postgres or MySQL! •  Redshift vs custom data warehouse! •  Elasticache vs on-instance Redis or memcached! •  EMR vs custom Hadoop! •  DynamoDB vs on-instance NoSQL!
  48. Part IV: Delivery!

  49. None
  50. Commit! Build! Test! Deploy!

  51. Simplified Git Flow! Master   Develop   Feature  1  

    Feature  2  
  52. •  Automatically run feature branches in the cloud! Personal Builds!

    personal.example.com Build server Commit to remote-run branch
  53. •  On-demand integration environment using Docker containers! Integration Testing! Build

    server 1. Get  dependencies   2. Run  unit  tests   3. Build     4. Start  containers   5. Run  integraKon  tests  using   containers  as    resources  
  54. Build Artifact!

  55. Deployment Approaches!

  56. www.example.com! Live Code! Blue/Green!

  57. www.example.com! Live Code! New Code! Blue/Green!

  58. www.example.com! Live Code! Rolling Release!

  59. www.example.com! New! Old! Old! Old! Rolling Release!

  60. www.example.com! New! New! Old! Old! Rolling Release!

  61. www.example.com! New! New! New! Rolling Release!

  62. www.example.com! Hybrid! Live! Live! Live!

  63. Live! Live! Live! New! New! New! www.example.com! Hybrid!

  64. www.example.com! Hybrid! New! New! New!

  65. Part I: Network
 Part II: Systems
 Part II: Applications
 Part

    IV: Delivery!
  66. “And that’s all I have to say about that.”! -

    Forrest Gump!
  67. Ben Whaley! ! bwhaley.com! @iAmTheWhaley!