Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Latency's Worst Nightmare: performance tuning tips and tricks

23,182 views

Published on

From request to response, this session will dive deep into identifying, measuring and reducing latency in your stack for lightning fast applications that keep your customers smiling. Learn how to architect for performance and fine tune your apps for speed with real world examples using the services you love: EC2, RDS, DynamoDB and S3.

Published in: Technology

Latency's Worst Nightmare: performance tuning tips and tricks

  1. 1. Latency’s Worst Nightmare:Performance Tuning Tips and Tricks Matt Wood Principal Data Scientist @mza
  2. 2. Hello.
  3. 3. Let’s talk about performance...
  4. 4. Productivity and response time A. J. Thadhani, IBM Systems Journal 20 (4), 1981
  5. 5. Page load time and average daily searches per user http://www.webperformancetoday.com/2013/04/10/cloud-connect-2013-web-acceleration-and-front-end-optimization-slides/
  6. 6. Page load delay and business metrics http://www.webperformancetoday.com/2013/04/10/cloud-connect-2013-web-acceleration-and-front-end-optimization-slides/
  7. 7. 2.2s 15.4%reduction in page load time increase in conversion rate https://blog.mozilla.org/metrics/2010/04/05/firefox-page-load-speed-%E2%80%93-part-ii/
  8. 8. “Speed is more than a feature.” @fredwilson
  9. 9. Let’s talk about a web request...
  10. 10. %CPUkbps Initial connection SSL negotiation Time to first byte Content download
  11. 11. Remote%CPUkbps Initial connection SSL negotiation Time to first byte Content download
  12. 12. Remote Browser%CPUkbps Initial connection SSL negotiation Time to first byte Content download
  13. 13. Remote Browser%CPUkbps Initial connection SSL negotiation Time to first byte Content download
  14. 14. http://www.stevesouders.com/blog/2012/02/10/the-performance-golden-rule/
  15. 15. Let’s talk about a web request...
  16. 16. Web serverApplication logic Database
  17. 17. Web serverApplication logic Database
  18. 18. Web serverApplication logic Database
  19. 19. Web serverApplication logic Database
  20. 20. Web serverApplication logic Database
  21. 21. Web serverApplication logic Database
  22. 22. Web serverApplication logic Database
  23. 23. Web serverApplication logic Database
  24. 24. 712 Web server3 Application logic4 Database5 6
  25. 25. 712 Web server3 Application logic4 Database5 6
  26. 26. TTFB%CPUkbps Initial connection SSL negotiation Time to first byte Content download
  27. 27. Network latency Download + negotiation time%CPUkbps Initial connection SSL negotiation Time to first byte Content download
  28. 28. NYC London SydneyVariable TTFB based on geographic location.
  29. 29. Reduce internet induced latency.CloudFront content delivery network. Lower latency. Faster downloads.
  30. 30. Reduce internet induced latency.CloudFront content delivery network. Lower latency. Faster downloads.
  31. 31. CloudFront Edge Locations
  32. 32. Static and dynamic content Cache dynamic pages (search results).Use query strings or cookie for cache keys.Network and Path optimizations accelerate even unique content.
  33. 33. 7 Content delivery12 Web server3 Application logic4 Database5 6
  34. 34. 7 Content delivery12 Web server3 Application logic4 Database5 6
  35. 35. Web serverApplication server
  36. 36. Web serverApplication server
  37. 37. Application server
  38. 38. Thread safe?Application state? Application server
  39. 39. Web serverApplication server Database
  40. 40. Unit of scale Web server Application server
  41. 41. Load balancer Web serverApplication server
  42. 42. Load balancer Web server Web server Web serverApplication server Application server Application server
  43. 43. Load balancer Web server Web server Web serverApplication server Application server Application server
  44. 44. Load balancer Web server Web server Web serverApplication server Application server Application server
  45. 45. Decouple your service tiers Separation of concerns. Easier to manage. Drives higher availability.
  46. 46. Build for horizontal scale Decrease request contention. Reduce capacity planning headaches.Requires a stateless application architecture.
  47. 47. Small things, loosely coupled. Do one thing, and do it well. The Unix Way.Take a look at the Unicorn and Rainbows approach. Asynchronous be default (where possible).
  48. 48. Reduce response time. Concurrency limits can reappear quickly.Limit impact on performance through rapid scaling.
  49. 49. Load balancer
  50. 50. Load balancer
  51. 51. Load balancer
  52. 52. Fast booting with EBS-backed instances. Linux is faster to boot than Windows.EBS-backed instances are faster than S3 backed.
  53. 53. Pre-baked EBS-backed AMIs.Each code deployment creates a new AMI. AMI is the unit of deployment.
  54. 54. Automate response with Auto Scaling. Set operational thresholds.Faster than manual response (especially at 3am).
  55. 55. Time-based response with OpsWorks. Set operational times. ‘Follow the sun’ response.
  56. 56. Pre-emptive scaling. Contact your account manager, orget in touch via a Premium Support ticket.
  57. 57. Reserve capacity. Lower costs.Guaranteed availability.
  58. 58. 7 Content delivery1 Horizontal scale234 Database5 6
  59. 59. 7 Content delivery1 Horizontal scale234 Database5 6
  60. 60. A range of instance typesFull spectrum of price/performance options.
  61. 61. Choosing the right instance type. Application specific. Benchmark. CloudWatch metrics.
  62. 62. Benchmark on business metrics.Relate application metrics to business metrics. Customers supported/instance. Photos processed/dollar.
  63. 63. The Canary in the Coal Mine Standardize on 64-bit AMIs. Deploy across instance types.Evaluate new instance types with real traffic.
  64. 64. 7 Content delivery1 Horizontal scale2 Instance selection34 Database5 6
  65. 65. 7 Content delivery1 Horizontal scale2 Instance selection34 Database5 6
  66. 66. Interface with the data store.Faster if you don’t have to go to disk. Increased concurrency.
  67. 67. Caching.Store query results in memory. Writes go to disk.
  68. 68. Amazon ElastiCache.Deploy, operate and scale in-memory caches.
  69. 69. Managing state. Transient data only.Web server state, high score tables, etc. Time consuming task results (many to many query results).
  70. 70. Best practices.Assume cold cache latency in application architecture. Set appropriate time-to-live. Batch requests rather than sequential single. Architect for cache failure.
  71. 71. 7 Content delivery1 Horizontal scale2 Instance selection3 Caching4 Database5 6
  72. 72. 7 Content delivery1 Horizontal scale2 Instance selection3 Caching4 Database5 6
  73. 73. Accelerating reads.Vertical scale vs horizontal scale.
  74. 74. Horizontal scale.Add additional DB resources for scale. Scale out for reads. Shard for reads and writes.
  75. 75. Vertical scale.More resources for a single DB engine. Add memory for DB caches. Add CPU for more intensive queries.
  76. 76. Scaling IO. Provision throughput for your app. Reserved. Available. Elastic.Available on EBS, Amazon RDS and DynamoDB.
  77. 77. Provisioned throughput is consistent. Consistent, predictable performance. Relational databases with RDS. NoSQL stores with DynamoDB.Relational & NoSQL with EC2 and EBS.
  78. 78. Provisioned throughput with RDS. 12.5k IOPS on MySQL. 25k IOPS on Oracle. 10k IOPS on SQL Server.Provision up to 30k for reduced latency.
  79. 79. Provisioned throughput and instance types. Optimized for provisioned IO storage: m1.large: 500 Mbpsm1.xlarge, m2.xlarge, m2.4xlarge: 1000 Mbps
  80. 80. Provisioned throughput and DynamoDB. Consistent performance with unlimited throughput and storage. Single digital latency.
  81. 81. Build for a uniform workload.Evenly distribute query patterns by key. Use a wide range of key values.
  82. 82. 7 Content delivery1 Horizontal scale2 Instance selection3 Caching4 Read capacity5 6
  83. 83. 7 Content delivery1 Horizontal scale2 Instance selection3 Caching4 Read capacity5 6
  84. 84. Standard EBS volumes. Moderate or bursty workloads.100 IOPS, bursting to hundreds of IOPS. Bursting is good for boot volumes.
  85. 85. Provisioned IOPS with EBS volumes.Predictable, high performance for I/O-intensive workloads. 2000 IOPS per volume. Stripe volumes for additional I/O.Deliver within 10% of the performance, 99.9% of the time.
  86. 86. EBS-Optimized instances. m1.large, m2.2xlarge, m3.xlarge: 500 Mbpsm1.xlarge, m2.4xlarge, m3.2xlarge, c1.xlarge: 1000 Mbps
  87. 87. High bandwidth networkingcg1.4xlarge, cc2.8xlarge, hi1.4xlarge, hs1.8xlarge andcr1.8xlarge run on non-blocking, 10 gigabit networking. Not EBS-Optimized, but can be used with provisioned IOPS volumes.
  88. 88. High I/O instancesDesigned for for high throughput database workloads. 2 x 1 TB SSDs 2 GB/s for reads 1.1 GB/s for writes
  89. 89. PVM instances 4 KB random reads: 120K IOPS4 KB random writes: 10K–80K IOPS
  90. 90. HVM instances (including Windows) 4 KB random reads: 90K IOPS 4 KB random writes: 9K–75K IOPS
  91. 91. High Storage instances High sequential I/O. 24 x 2 TB drives.2.4 GB/s of 2 MiB sequential reads. 2.6 GB/s for sequential writes.
  92. 92. 7 Content delivery1 Horizontal scale2 Instance selection3 Caching4 Read capacity Block store5 6
  93. 93. Back end Front end%CPUkbps Initial connection SSL negotiation Time to first byte Content download
  94. 94. http://amzn.to/170S1VV http://amzn.to/Zod4PY
  95. 95. 14 rules for faster loading web sites1. Make fewer HTTP requests. 8. Make JavaScript and CSS External.2. Use a content delivery network. 9. Reduce DNS lookups.3. Add an expires header. 10. Minify Javascript.4. GZIP components. 11. Avoid redirects.5. Put style sheets at the top. 12. Remove duplicate scripts.6. Put scripts at the bottom. 13. Configure ETags.7. Avoid CSS expressions. 14. Make AJAX cacheable. http://stevesouders.com/hpws/rules.php
  96. 96. Front end optimization 7 Content delivery1 Horizontal scale2 Instance selection3 Caching4 Read capacity Block store5 6
  97. 97. One more thing...
  98. 98. US East
  99. 99. Route 53Sydney US East Dublin
  100. 100. Thank you!matthew@amazon.com@mza

×