Best Practices for Hosting Web Applications on AWS

5,886 views

Published on

Published in: Technology
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,886
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
0
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide

Best Practices for Hosting Web Applications on AWS

  1. 1. Best Practices For Hosting Web Applications on AWS Jeff Barr Senior Web Services Evangelist @jeffbarr Matt Tavis Solutions Architect
  2. 2. Today’s Agenda Availability Static content Multi-tier applications Summary
  3. 3. Spectrum of Websites
  4. 4. Spectrum of WebsitesStatic Dynamic
  5. 5. Spectrum of WebsitesStatic DynamicSimple Complex
  6. 6. Spectrum of WebsitesStatic DynamicSimple ComplexNiche Mass Market
  7. 7. Get Your Priorities Straight Availability is important  Support your customers  Support your business However…
  8. 8. Everything fails all the time Werner Vogels, Amazon CTO
  9. 9. Infrastructure Services Can Save The Day
  10. 10. Your Data is a Royal Garden
  11. 11. Your Infrastructructure is a Fungible Resource
  12. 12. Patterns for High Availability
  13. 13. Pattern 1Static Content
  14. 14. ImagesStylesheets Streaming contentWeb pages Web Assets Blog posts PDFs Javascript Videos
  15. 15. High HighRedundancy Availability Amazon S3 High durability
  16. 16. S3 Object Access URLs http://s3.amazonaws.com/bucketname/objectid http://bucketname.s3.amazonaws.com/objectid https://s3.amazonaws.com/bucketname/objectid https://bucketname.s3.amazonaws.com/objectid
  17. 17. S3 Uses Perfect for asset hosting Perfect for website hosting Let’s see how…
  18. 18. aws.amazon.com/console
  19. 19. Make everything public
  20. 20. https://s3.amazonaws.com/jbarr/site/index.html
  21. 21. However…. Brittle, unfriendly URL S3 website hosting Root objects Error pages
  22. 22. http://jbarr.s3-website-us-east-1.amazonaws.com/
  23. 23. Content Distribution – Amazon CloudFront Speed of light causes increased latency with distance….
  24. 24. Amazon CloudFront Global edge caching (18 locations) Friendly URLs – default root object Distribution-based Let’s see how…
  25. 25. d3e7617hqtdwhu.cloudfront.net
  26. 26. http://d3e7617hqtdwhu.cloudfront.net/site/jeffbarr.jpg
  27. 27. What Did We Do? Upload website to S3 Create CloudFront Distribution Make site (file and image) accessible with low latency Current CloudFront edge locations: • Ashburn, VA • St. Louis, MO • Dallas/Fort Worth, TX • Amsterdam • Jacksonville, FL • Dublin • Los Angeles, CA • Frankfurt • Miami, FL • London • New York, NY • Paris • Newark, NJ • Hong Kong • Palo Alto, CA • Tokyo • Seattle, WA • Singapore
  28. 28. Update DNS Entry www.jeff-barr.com
  29. 29. What We Have Built www.jeff-barr.com Global DNS CNAME Global Amazon CloudFront Regional Amazon S3 Redundant storage
  30. 30. Pattern 2Dynamic or Multi-Tier Content
  31. 31. Ruby on Rails PHP DjangoPerl Dynamic Spring Database Data store
  32. 32. Blogs E-commerce Gaming Dynamic AppsProductivity Social networks
  33. 33. Elastic MultipleCapacity Instance Sizes Amazon EC2 On-demand
  34. 34. Mastering Multiple failure availability zones High Availability Automation and monitoring
  35. 35. High Availability With EC2 Single Server Fail Over
  36. 36. High Availability With EC2 Elastic IP Address EC2 Instance EBS Storage EBS Snapshot
  37. 37. Instance Failure Elastic IP Address EC2 Instance EBS Storage EBS Snapshot
  38. 38. Instance Failure – Replace Instance Elastic IP Address EC2 Instance EC2 Instance EBS Storage EBS Snapshot
  39. 39. Instance Failure –Back to Normal Elastic IP Address EC2 Instance EBS Storage EBS Snapshot
  40. 40. Attributes Inexpensive but not ideal Requires monitoring and automation Allows for ‘hot swap’
  41. 41. High Availability With EC2 Horizontal Redundancyfor Multi-Tier Applications
  42. 42. Multiple Tiers Web Servers Application Servers Data Store
  43. 43. Multiple Tiers with Redundancy at Each Tier Web Servers Web Servers Web Servers Application Servers Application Servers Application Servers Data Store Data Store Data Store
  44. 44. This Architecture Tolerates Instance Failure Web Servers Web Servers Web Servers Application Servers Application Servers Application Servers Data Store Data Store Data Store
  45. 45. Tolerant to Availability Zone Failure Elastic Load Balancer Web Servers Web Servers Web Servers Web Servers Web Servers Web Servers Application Servers Application Servers Application Servers Application Servers Application Servers Application Servers Data Store Data Store Data Store Data Store Data Store Data Store US-East-1A US-East-1B US-East
  46. 46. Scale In and Scale Out as Needed Web Servers Web Servers Web Servers ApplicationServers Servers ApplicationServers ApplicationServers ApplicationServers Application Application Servers Data Store Data Store
  47. 47. Spinning Up a Multi-Tier Application
  48. 48. Create MySQL server withAmazon RDS
  49. 49. Launch 4 EC2Micro Instances
  50. 50. Create an Elastic Load Balancer
  51. 51. Add my instances to the load balancer
  52. 52. Database Scaling Scale Up CPU Add Storage Add Redundancy
  53. 53. Database Scaling – Add Read Replicas
  54. 54. Recovering From FailuresAuto-Healing and Auto-Scaling
  55. 55. Elastic Load BalancingCloudWatch Auto Scaling
  56. 56. Create Launch Configurationas-create-launch-config MyConfig --image-id ami-123456 --instance-type m1.small --key jbarr-key --group “Web and SSH”
  57. 57. Create Auto Scaling Groupas-create-auto-scaling-group MyScalingGroup --launch-configuration MyConfig --availability-zones us-east-1a,us-east-1b --min-size 5 --max-size 10 --load-balancers demo-load-balancer Keep at least 5 and as many as 10 instances running!
  58. 58. Set Scaling Rulesas-create-or-update-trigger CPUUtilization DiskReadBytes DiskReadOps DiskWriteBytes DiskWriteOps NetworkIn NetworkOut FreeStorageSpace ReadLatency …
  59. 59. SummaryWhat We Have Seen and Learned
  60. 60. What We Have Learned Importance of high availability Hosting assets on S3 Content distribution with CloudFront Web applications and EC2 Multi-tier application hosting Database management with RDS
  61. 61. Q&A
  62. 62. Thank You!

×