Your First Week on Amazon EC2
Dhruv Parpia
Solution Architect ASEAN, AWS
July18, 2013
Questions for Your First Week on Amazon EC2
• What is Amazon EC2?
• Where do I start with EC2?
– What are the components o...
An Approach to Your First Week on Amazon EC2
• Leverage what you already know about web architectures
• Understand enough ...
Day 1 – Identify and Deploy Application on EC2
Region
Availability Zone
Linux
Apache
Ruby
MySQL
Source Protocol Port
0.0.0...
Day 1 – Launching Your First EC2 Instance
1. Login to the AWS Management Console and go to the Amazon EC2 console
2. Choos...
Day 1 – Choose AMI
Day 1 – Instance Details
Day 1 – Instance user-data
Day 1 – Tags
Day 1 – Create Key Pair
Day 1 – Configure Firewall
Day 1 – Instance Launched
Day 1 – Application Tasks
[laptop]$ ssh -i ~/ec2.pem ec2-user@ec2-54-254-126-114.ap-southeast-1.compute.amazonaws.com
__| ...
Day 1  Day 2
Day 1 Recap Day 2 Considerations
1. Created an AWS account
2. Identified an application for cloud
deployment...
Day 2 – Create a tiered architecture
Region
Availability Zone
Snapshot Amazon S3
Internet
User
HTTP (80)
Source Protocol P...
Day 2 – Launching a Tiered Web Application
1. Snapshot EC2 Instance
– Stop MySQL
– Bundle New AMI
2. Create a Relational D...
Day 2 – Create a snapshot of our AMI
Day 2 – New AMI
Day 2 – Launch RDS DB Instance
Day 2 – RDS DB Instance Details
Day 2 – RDS Management Options
Day 2 – Granting EC2 App Access to RDS
Day 2 – Connect to RDS Database
[ec2-user@ip-10-40-203-29 ~]$ mysql -uroot –p –D devdb 
–h nonprod.ctjsifycx3sq.ap-southea...
Day 2  Day 3
Day 2 Recap Day 3 Considerations
1. Took a snapshot of AMI as a backup
2. Created an RDS MySQL Database
3. C...
Day 3 – Monitor Environment
Region
Availability Zone
Internet User
Amazon
CloudWatch
Users
Alarm
Administrator
Email Notif...
Day 3 – Create CloudWatch Alarm
1. Select metric to monitor
– Database write latency is an accurate indicator of our appli...
Day 3 – Create Alarm
Day 3 – Create Alarm
Day 3  Day 4
Day 3 Recap Day 4 Considerations
1. Identified CloudWatch metrics
available for EC2 and RDS
2. Created a Clo...
Day 4 – Designing for High Availability
Region
Availability Zone
Internet
Amazon
CloudWatch
Users
Alarm
Availability Zone
...
Day 4 – Steps to High Availability
1. Create an Elastic Load Balancer (ELB)
– Balances traffic across multiple EC2 instanc...
Day 4 – Define Load Balancer
Day 4 – Configure Health Check
Day 4 – Add EC2 Instance(s)
Day 4 – Elastic Load Balancer is Active
Day 4 – Configure Auto Scaling
1. Use the Amazon Machine Image (AMI) we created
2. Leverage multiple Availability Zones
– ...
Day 4 – Find That AMI We Created
Day 4 – Set Up Auto Scaling
[laptop]$ as-create-launch-configuration webcfg 
--image-id ami-08dc4461 --instance-type m1.sm...
Day 4 – Setup Auto Scaling continued
[laptop]$ as-put-scaling-policy WebScaleUpPolicy 
--auto-scaling group webscg 
--adju...
Day 4 – Check on Our Instances
Day 4 – Set Up RDS Multi-AZ
[laptop]$ aws rds modify-db-instance 
--db-instance-identifier nonprod 
--multi-az --region ap...
Day 4  Day 5
Day 4 Recap Day 5 Considerations
1. Spread our application across
Availability Zones.
2. Automated scaling a...
Day 5 – DNS, Identity & Access Management, Deployment Automation
Region
Availability Zone
Internet
S3 Bucket
Amazon
CloudW...
Day 5 – Route 53 (DNS)
Day 5 – Identity & Access Management
Day 5 – Deployment Automation
First Week on Amazon EC2
• Evolution from Day 1  Day 5
– Single AMI  Tiered Monitored HA DNS, IAM, Automation
• Cloud...
…and Beyond
• Moving beyond week 1 on EC2
– AWS Management Console is great but you have other options
• Command Line Inte...
Technical Track
Upcoming SlideShare
Loading in...5
×

AWS Summit 2013 | Singapore - Your First Week with Amazon EC2

3,441

Published on

Amazon Elastic Compute Cloud (Amazon EC2) provides resizable compute capacity in the cloud and is often the starting point for your first week using AWS. This session will introduce these concepts, along with the fundamentals of EC2, by employing an agile approach that is made possible by the cloud. Attendees will experience the reality of what a first week on EC2 looks like from the perspective of someone deploying an actual application on EC2. You will follow them as they progress from deploying their entire application from an EC2 AMI on day 1 to more advanced features and patterns available in EC2 by day 5. Throughout the process we will identify cloud best practices that can be applied to your first week on EC2 and beyond.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,441
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

AWS Summit 2013 | Singapore - Your First Week with Amazon EC2

  1. 1. Your First Week on Amazon EC2 Dhruv Parpia Solution Architect ASEAN, AWS July18, 2013
  2. 2. Questions for Your First Week on Amazon EC2 • What is Amazon EC2? • Where do I start with EC2? – What are the components of EC2? – What are the big picture architecture cloud patterns? – What other Amazon Web Services should I use? • How do I map my existing infrastructure architecture to EC2? – How do I configure my environment for high availability? – How do manage my environment in the cloud? – How do I monitor my environment in the cloud?
  3. 3. An Approach to Your First Week on Amazon EC2 • Leverage what you already know about web architectures • Understand enough to get started with EC2 • Take an iterative approach – Refactor and evolve – Pay for what you use • Understand and apply cloud best practices – Capacity on demand – Elasticity – Design for failure – Infrastructure automation
  4. 4. Day 1 – Identify and Deploy Application on EC2 Region Availability Zone Linux Apache Ruby MySQL Source Protocol Port 0.0.0.0/0 HTTP 80 148.20.57.0/24 SSH 22
  5. 5. Day 1 – Launching Your First EC2 Instance 1. Login to the AWS Management Console and go to the Amazon EC2 console 2. Choose an Amazon Machine Image (AMI) 3. Choose an instance size 4. Create a key pair for SSH access 5. Create port-based security rules 6. Launch instance 7. Upload code
  6. 6. Day 1 – Choose AMI
  7. 7. Day 1 – Instance Details
  8. 8. Day 1 – Instance user-data
  9. 9. Day 1 – Tags
  10. 10. Day 1 – Create Key Pair
  11. 11. Day 1 – Configure Firewall
  12. 12. Day 1 – Instance Launched
  13. 13. Day 1 – Application Tasks [laptop]$ ssh -i ~/ec2.pem ec2-user@ec2-54-254-126-114.ap-southeast-1.compute.amazonaws.com __| __|_ ) _| ( / Amazon Linux AMI ___|___|___| https://aws.amazon.com/amazon-linux-ami/2013.03-release-notes/ There are 13 security update(s) out of 24 total update(s) available Run "sudo yum update" to apply all updates. [ec2-user@ip-10-40-203-29 ~]$ sudo yum -y -q update [ec2-user@ip-10-40-203-29 ~]$ sudo yum -y -q install httpd mysql-server ruby19 git [ec2-user@ip-10-40-203-29 ~]$ sudo service mysqld start [ec2-user@ip-10-40-203-29 ~]$ sudo /etc/init.d/httpd start
  14. 14. Day 1  Day 2 Day 1 Recap Day 2 Considerations 1. Created an AWS account 2. Identified an application for cloud deployment 3. Logged into the Web Console 4. Chose an AMI 5. Launched an EC2 instance 6. Setup application • How can we capture our work efforts to make them repeatable or recover from failure? • What options do we have for setting up a tiered architecture? • How can we apply security to our instances?
  15. 15. Day 2 – Create a tiered architecture Region Availability Zone Snapshot Amazon S3 Internet User HTTP (80) Source Protocol Port 0.0.0.0/0 HTTP 80 148.20.57.0/2 4 SSH 22 Connection Type Details EC2 Security Group web-tier-sg
  16. 16. Day 2 – Launching a Tiered Web Application 1. Snapshot EC2 Instance – Stop MySQL – Bundle New AMI 2. Create a Relational Database (RDS) Instance – We’ll use MySQL – Other options: Oracle, SQL Server 3. Configure App to Use RDS MySQL Database
  17. 17. Day 2 – Create a snapshot of our AMI
  18. 18. Day 2 – New AMI
  19. 19. Day 2 – Launch RDS DB Instance
  20. 20. Day 2 – RDS DB Instance Details
  21. 21. Day 2 – RDS Management Options
  22. 22. Day 2 – Granting EC2 App Access to RDS
  23. 23. Day 2 – Connect to RDS Database [ec2-user@ip-10-40-203-29 ~]$ mysql -uroot –p –D devdb –h nonprod.ctjsifycx3sq.ap-southeast-1.rds.amazonaws.com Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 268 Server version: 5.5.27-log Source distribution Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>
  24. 24. Day 2  Day 3 Day 2 Recap Day 3 Considerations 1. Took a snapshot of AMI as a backup 2. Created an RDS MySQL Database 3. Created and validated security groups • What tools does AWS provide to monitor EC2 and RDS? • How can we better monitor the our environment (proactive vs. reactive)? • How can we be notified when our servers hits certain thresholds?
  25. 25. Day 3 – Monitor Environment Region Availability Zone Internet User Amazon CloudWatch Users Alarm Administrator Email Notification
  26. 26. Day 3 – Create CloudWatch Alarm 1. Select metric to monitor – Database write latency is an accurate indicator of our application’s health 2. Define a threshold – Write latency that exceeds 500ms typically requires some intervention on our part 3. Create a topic for our alarm and subscribe to the topic via email
  27. 27. Day 3 – Create Alarm
  28. 28. Day 3 – Create Alarm
  29. 29. Day 3  Day 4 Day 3 Recap Day 4 Considerations 1. Identified CloudWatch metrics available for EC2 and RDS 2. Created a CloudWatch alarm 3. Set up alarm to email on failure 4. Reviewed CloudWatch dashboard • What happens if our EC2 instance fails? • What happens if an entire AZ is unavailable? • How can we elastically scale based on increased/decreased traffic? • What happens if our primary RDS instance fails?
  30. 30. Day 4 – Designing for High Availability Region Availability Zone Internet Amazon CloudWatch Users Alarm Availability Zone RDS DB Standby Auto scaling Group
  31. 31. Day 4 – Steps to High Availability 1. Create an Elastic Load Balancer (ELB) – Balances traffic across multiple EC2 instances – Enables running instances in multiple Availability Zones (AZ’s) 2. Configure Auto Scaling – Automatically scale up if demand increases – And scale down to save money 3. Setup RDS Multi-AZ – Synchronous replication to standby in another AZ – Automatically fails over if needed – Also minimizes backup window (slave is used)
  32. 32. Day 4 – Define Load Balancer
  33. 33. Day 4 – Configure Health Check
  34. 34. Day 4 – Add EC2 Instance(s)
  35. 35. Day 4 – Elastic Load Balancer is Active
  36. 36. Day 4 – Configure Auto Scaling 1. Use the Amazon Machine Image (AMI) we created 2. Leverage multiple Availability Zones – Distribute instances across two AZ’s – Ensure at least two instances are up 3. Create an Auto Scaling trigger – Same concept as CloudWatch alarm from earlier – Just now we’re proactively taking action
  37. 37. Day 4 – Find That AMI We Created
  38. 38. Day 4 – Set Up Auto Scaling [laptop]$ as-create-launch-configuration webcfg --image-id ami-08dc4461 --instance-type m1.small --region ap-southeast-1 [laptop]$ as-create-auto-scaling-group webscg --launch-configuration-name webcfg --availability-zones ap-southeast-1a ap-southeast-1b --min-size 2 --max-size 10 --load-balancer-names frontlb
  39. 39. Day 4 – Setup Auto Scaling continued [laptop]$ as-put-scaling-policy WebScaleUpPolicy --auto-scaling group webscg --adjustment=1 --type ChangeInCapacity --cooldown 300 [laptop]$ mon-put-metric-alarm WebHighCPUAlarm --comparison-operator Greater ThanThreshold --evaluation-periods 1 --metric-name CPUUtilization --namespace "AWS/EC2" --period 600 --statistic Average --threshold 80 --alarm-actions POLICY-ARN_from_previous_step --dimensions "AutoScalingGroup Name=webscg"
  40. 40. Day 4 – Check on Our Instances
  41. 41. Day 4 – Set Up RDS Multi-AZ [laptop]$ aws rds modify-db-instance --db-instance-identifier nonprod --multi-az --region ap-southeast-1 Yep, that’s it. No mouse required. :)
  42. 42. Day 4  Day 5 Day 4 Recap Day 5 Considerations 1. Spread our application across Availability Zones. 2. Automated scaling across availability zone leveraging Auto Scaling. 3. Implemented load balancing via AWS Elastic Load Balancing. 4. Implemented a highly available database by applying RDS multi-AZ. • How do we make use of a custom DNS domain for our load balancer? • How can we configure accounts for other AWS users? • How can we template and replicate our server environment?
  43. 43. Day 5 – DNS, Identity & Access Management, Deployment Automation Region Availability Zone Internet S3 Bucket Amazon CloudWatch Users Alarm Availability Zone RDS DB Standby AWS IAM www.example.com AWS Management Console AWS CloudFormation TemplateStack images.example.com
  44. 44. Day 5 – Route 53 (DNS)
  45. 45. Day 5 – Identity & Access Management
  46. 46. Day 5 – Deployment Automation
  47. 47. First Week on Amazon EC2 • Evolution from Day 1  Day 5 – Single AMI  Tiered Monitored HA DNS, IAM, Automation • Cloud architecture best practices implemented in week 1 on EC2 – Proactive scaling – Auto scaling triggers – Elasticity – EC2 – Design for failure – ELB, Auto scaling groups, Availability Zones – Decouple your components – EC2, RDS – Infrastructure automation – CloudFormation
  48. 48. …and Beyond • Moving beyond week 1 on EC2 – AWS Management Console is great but you have other options • Command Line Interface • API – Other AWS Services • VPC, Elasticache, OpsWorks, Beanstalk, DynamoDB, SQS – Operational Checklist • http://media.amazonwebservices.com/AWS_Operational_Checklists.pdf – Deployment Automation • http://aws.amazon.com/cloudformation/aws-cloudformation-articles-and-tutorials/ – Links to whitepapers and architectures • http://aws.amazon.com/whitepapers/ • http://aws.amazon.com/architecture/
  49. 49. Technical Track

×