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

High Performance Web Applications

Matt Wood
October 29, 2012

High Performance Web Applications

Building high performance web applications on AWS.

Matt Wood

October 29, 2012
Tweet

More Decks by Matt Wood

Other Decks in Technology

Transcript

  1. High Performance
    Web Applications
    [email protected]
    Dr. Matt Wood
    @mza

    View Slide

  2. Hello

    View Slide

  3. Building blocks for wonderful applications
    Storage, compute, databases, managed services

    View Slide

  4. View Slide

  5. Retail Merchant
    services
    Web
    services

    View Slide

  6. Retail Merchant
    services
    Web
    services

    View Slide

  7. Getting started with
    Amazon Web Services
    quick review
    H

    View Slide

  8. Utility computing
    Available at the end of an API call.
    Metered billing.
    H

    View Slide

  9. Family of 20 services
    Adding new services and refinement weekly.
    Rapid rate of innovation.
    H

    View Slide

  10. Undi!erentiated heavy lifting
    Focus on your app, customers and business
    H

    View Slide

  11. H

    View Slide

  12. aws.amazon.com
    H
    Free account.
    Free tier.

    View Slide

  13. Building High Performance
    Web Applications
    r

    View Slide

  14. Deliver a great experience to
    your customers.
    Responsive, fast web applications.
    r

    View Slide

  15. g DECOUPLED
    SCALE
    OUT
    S
    OPTIMIZE COST
    FOR
    C
    AUTOMATE
    v CALIBRATED FOR:
    CPU performance v CALIBRATED FOR:
    IO performance
    5patterns for
    performance

    View Slide

  16. g DECOUPLED

    View Slide

  17. Monolithic Mega System v2

    View Slide

  18. Application
    Assets
    Analytics

    View Slide

  19. Application
    Assets
    Analytics

    View Slide

  20. Images, javascript, stylesheets,
    HTML pages
    Deliver as fast as possible to customers
    r

    View Slide

  21. Websites without the servers
    Highly durable: 99.999999999%
    Zero config: fire and forget
    r

    View Slide

  22. View Slide

  23. Low latency delivery of assets
    Local caching for fast downloads
    Amazon CloudFront
    r

    View Slide

  24. P
    P

    View Slide

  25. Create content distributions
    From objects in S3
    Any custom origin
    Dynamic, streaming and static content
    r

    View Slide

  26. P
    P
    P

    View Slide

  27. CNAME?
    Map to any custom URL
    assets.domain.com, www.domain.com
    r

    View Slide

  28. Application
    Assets
    Analytics

    View Slide

  29. Application
    Assets
    Analytics

    View Slide

  30. Application architecture
    Small things, loosely coupled
    r

    View Slide

  31. Application
    Assets
    Analytics

    View Slide

  32. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  33. Shared responsibility
    Infrastructure by AWS
    OS, application and data by customers
    Tools to help meet best practices
    r

    View Slide

  34. Security groups
    Customer controlled firewalls
    All ports are closed by default
    r

    View Slide

  35. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  36. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics
    x

    View Slide

  37. Decoupling provides an architectural
    framework for performance
    Easier to separate concerns: assets, streaming, etc.
    Easier to manage and scale.
    r

    View Slide

  38. SCALE
    OUT

    View Slide

  39. Elasticity is a tenet of the cloud
    Scale up when you need to
    Scale down when you don’t
    r

    View Slide

  40. Predictable peaks
    r
    Time
    Demand
    Capacity

    View Slide

  41. Predictable peaks
    r
    Time
    Demand
    Capacity

    View Slide

  42. Variable usage
    r
    Time
    Demand
    Capacity

    View Slide

  43. Variable usage
    r
    Time
    Demand
    Capacity

    View Slide

  44. Variable usage
    r
    Time
    Demand

    View Slide

  45. Horizontal scaling
    drives performance up
    ...and costs down
    r

    View Slide

  46. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  47. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  48. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  49. Amazon Machine Images
    encapsulate your app
    Customize your virtual machines
    AMI can be the unit of deployment
    r

    View Slide

  50. 1. Spin up a new instance
    using your AMI
    Configured to bootstrap the app.
    r

    View Slide

  51. 2. Pull down latest code base
    From S3 or code repository
    r

    View Slide

  52. 3. Start up the app on the instance
    Ready to receive requests
    r

    View Slide

  53. 4. Register with the load balancer
    Job done.
    r

    View Slide

  54. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  55. Horizontal scaling allows for
    fault tolerance
    r

    View Slide

  56. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  57. Load balancer
    App servers
    Database
    Asynchronous processing
    :(
    Application
    Assets
    Analytics

    View Slide

  58. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  59. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  60. Deploying and scaling a datastore
    r
    Follow the same patterns:
    horizontal scale, availability, automation.

    View Slide

  61. One question:
    r
    Does your application require a
    strict, controlled schema for query flexibility?

    View Slide

  62. Amazon Relational Database Service
    r
    Management systems: CRM, ERP, finance
    Does your application require a strict, controlled schema
    for query flexibility? Yes

    View Slide

  63. Focus on your app
    r
    Handles tedious database admin tasks
    Designed for availability

    View Slide

  64. Multi-engine
    r
    MySQL, Oracle, Microsoft SQL Server
    Up and running in six clicks

    View Slide

  65. Point in time snapshots
    r
    Automatic. Easy recovery.

    View Slide

  66. High availability
    r
    Deployed across multiple availability zones.
    Synchronous writes.

    View Slide

  67. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  68. Read replicas
    r
    Perfect for read heavy applications.
    Asynchronous writes.
    Replication metrics available.

    View Slide

  69. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  70. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  71. Amazon DynamoDB
    r
    Web apps, social apps, mobile apps,
    user generated content,
    unstructured data integration, lots of data.
    Does your application require a strict, controlled schema
    for query flexibility? No

    View Slide

  72. Focus on your app
    r
    Managed NoSQL database service.
    No schema.

    View Slide

  73. Unlimited scale
    r
    Unlimited storage
    Pay as you go

    View Slide

  74. High performance
    r
    Single digit millisecond latencies

    View Slide

  75. Zero admin
    r
    No instances to manage
    Tiny API, perfectly formed

    View Slide

  76. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  77. Asynchronous processing
    r
    Resize images. Transcode movies.
    Resample media.

    View Slide

  78. Follow the same best practices
    r
    Decouple. Stateless. Horizontal scale.

    View Slide

  79. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  80. CloudFront for dynamic content
    r
    Edge caching for dynamic content
    Cache by query string parameters
    Multiple origin servers
    Persistent connections to origin servers

    View Slide

  81. C
    AUTOMATE

    View Slide

  82. Automate everything
    The tedious.
    The time consuming.
    The error prone.
    r

    View Slide

  83. For example:
    when increasing capacity
    Launch instance.
    Update application code.
    Register with load balancer.
    r

    View Slide

  84. Auto-scaling
    CloudWatch
    Auto-scaling service
    Elastic Load Balancer
    r

    View Slide

  85. Set operational thresholds
    Network capacity > 80%
    Memory utilization > 75%
    CPU < 50%
    r

    View Slide

  86. Automatically respond to
    operational alarms
    r
    Network capacity > 80%: add instances
    Memory utilization > 75%: add instances
    CPU < 50%: remove instances

    View Slide

  87. Set bounds
    Step change configured by number or
    percentage of instances
    r

    View Slide

  88. Custom metrics
    Respond to custom metrics
    Page load time
    Database query time
    r

    View Slide

  89. Automatic load balancer
    configuration
    Instances added/removed automatically
    Health check for running application before
    routing tra"c
    r

    View Slide

  90. Stateless operations are important
    Decoupled, but stateless
    Instances are naive to other instances
    r

    View Slide

  91. Treat your data as a royal garden
    Backup to S3: high durability
    Compute is a disposable resource
    r

    View Slide

  92. v CALIBRATED FOR:
    CPU performance

    View Slide

  93. Range of resources
    Choose the best instance type
    for performance
    r

    View Slide

  94. r
    t1.micro m1.small cc2.8xlarge

    View Slide

  95. r
    t1.micro m1.small cc2.8xlarge
    High memory
    High CPU
    High CPU + memory

    View Slide

  96. Load balancer
    App servers
    Database
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  97. 1 instance for 100 hours
    =
    100 instances for 1 hour

    View Slide

  98. Balance cost/performance
    Mix instance types for application servers,
    databases, ancillary services, analytics etc.
    r

    View Slide

  99. Migrate to large instance types
    As your application grows
    Use 64 bit from the outset, if possible
    r

    View Slide

  100. v CALIBRATED FOR:
    IO performance

    View Slide

  101. IO bound web applications are
    more common
    Application requires predictable, consistent IO
    r

    View Slide

  102. Provisioned throughput with
    DynamoDB
    No need to provision storage
    Provision IO requirements:
    reads and writes per second
    r

    View Slide

  103. View Slide

  104. View Slide

  105. View Slide

  106. View Slide

  107. Scale up, and carry on
    DynamoDB will manage resources to
    achieve and maintain throughput
    r

    View Slide

  108. Low latency, unlimited scale
    Writes acknowledged when saved to disk in
    multiple data centres. Backed on SSDs.
    r

    View Slide

  109. ...and SSDs for all

    View Slide

  110. hi1.4xlarge instances
    High capacity, high performance storage
    2 x 1Tb SSD drives
    r

    View Slide

  111. Perfect match for databases
    Relational and NoSQL storage
    r

    View Slide

  112. Perfect match for databases
    Relational and NoSQL storage
    90k to 120k IOPS
    r

    View Slide

  113. High performance network
    10 gigabit ethernet
    Placement groups
    Perfect for distributed stores
    r

    View Slide

  114. S
    OPTIMIZE COST
    FOR

    View Slide

  115. Economies of scale
    Drive down prices for customers
    20 price drops in past 6 years
    r

    View Slide

  116. Maximize utilization
    Greater utilization drives down cost
    r

    View Slide

  117. Reserved capacity
    Time
    Utilization

    View Slide

  118. Reserved instances
    Small upfront payment
    Guaranteed capacity for 1 or 3 years
    Lower hourly rate
    r

    View Slide

  119. Reserved instance resale
    Sell your reservations on the resale market
    Sellers set your own price
    Buyers select and check out
    r

    View Slide

  120. Reserved capacity
    Time
    Utilization

    View Slide

  121. Reserved capacity
    On-demand
    Time
    Utilization

    View Slide

  122. Reserved capacity
    On-demand
    Time
    Utilization

    View Slide

  123. Spot instances
    Name your price computing
    r

    View Slide

  124. Spot instances
    Lower costs
    ‘Overclock’ your app: more bang for your buck
    r

    View Slide

  125. Load balancer
    App servers
    Database on SSDs
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  126. Load balancer
    App servers
    Database on SSDs
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  127. Load balancer
    App servers
    Database on SSDs
    Asynchronous processing
    Application
    Assets
    Analytics

    View Slide

  128. Become price aware
    Price is a driver of your architecture
    r

    View Slide

  129. Automated bidding
    Automate bids based on on-demand price
    Run on spot only when cost e!ective
    r

    View Slide

  130. Continuous cost optimization
    Evaluate your reserved instance/on-demand/
    spot mix regularly as app requirements change
    r

    View Slide

  131. 5patterns for
    performance
    g DECOUPLED

    View Slide

  132. 5patterns for
    performance
    g DECOUPLED
    SCALE
    OUT

    View Slide

  133. 5patterns for
    performance
    g DECOUPLED
    SCALE
    OUT
    S
    OPTIMIZE COST
    FOR

    View Slide

  134. 5patterns for
    performance
    g DECOUPLED
    SCALE
    OUT
    S
    OPTIMIZE COST
    FOR
    v CALIBRATED FOR:
    CPU performance v CALIBRATED FOR:
    IO performance

    View Slide

  135. 5patterns for
    performance
    g DECOUPLED
    SCALE
    OUT
    S
    OPTIMIZE COST
    FOR
    v CALIBRATED FOR:
    CPU performance v CALIBRATED FOR:
    IO performance
    C
    AUTOMATE

    View Slide

  136. Thank you
    aws.amazon.com
    @mza
    [email protected]

    View Slide