Slide 1

Slide 1 text

Intro to Scaling your Web App on the Cloud with AWS (for Frontend Developers) Mauvis Ledford CTO, Pathbrite @krunkosaurus

Slide 2

Slide 2 text

Goals of this talk Philosophy •  Understand the common components of any Web Application Architecture and how they apply to AWS. •  Understand the pieces that form “The Cloud” and the mindset you should have when building upon it. Action •  Regardless of your experience level, get you up and running and experimenting with the AWS. It’s relatively cheap, fun, and the future of web hosting. 2

Slide 3

Slide 3 text

Overview 1.  Server and Network Basics 2.  Virtualization and the Cloud 3.  Why Amazon Cloud? 4.  The Cloud Philosophy 5.  Major Components of the AWS Dashboard 6.  Setting up Your First EC2 Instance 7.  Further Reading 3 What we’re going to cover

Slide 4

Slide 4 text

Server and Network Basics •  Server: Just a computer connected to the internet and used for serving data. Usually fast and on 24x7. Your laptop can be a server. •  IP Address: A number assigned to each computer on a network used for communication. For example 10.0.0.1. •  DNS: Also known as Domain Name System, is a distribution system that maps IP address to domain names so that you don’t have to remember IP addresses. For example “google.com” resolves to 74.125.224.67. •  Port: A communication endpoint that a servers listens for requests on. The default port for webpages is port 80. When you type “google.com” in a web browser, it is actually visiting: 74.125.224.67:80 •  CDN: Or Content Delivery Network. Big, dumb, computers set up around the world to serve your static assets really fast. •  Load Balancer: A piece of hardware or software that distributes load across many servers. 4 The Lingo

Slide 5

Slide 5 text

Server and Network Basics •  Linux: Free, stable, secure, and open-source operating system used by most servers. It comes in many versions, all similar but with some differences. Our preference is CentOS. –  Linux is based on Unix, an older operating system, and if you use a Mac, it’s “guts” are based on Unix, too. That’s why the command line is similar. –  Though Linux can come with a GUI, for performance reasons, it is not generally installed on servers. You should get comfortable with the command line if not already. 5 The Lingo •  Virtual Machine: A software abstraction that emulate the computer architecture and functions of a real computer. A computer can contain many virtual machines with their own operating systems each with an allotted percentage of CPU power and other resources. –  The operating system doesn’t know or care that it’s running in a virtual environment. –  The Cloud consists of virtual machines. Image  from:  h,p://www.y-­‐tech.net/userfiles/image/Hos

Slide 6

Slide 6 text

Virtualization and the Cloud 6 The problem of unpredictable usage From:  h,p://media.amazonwebservices.com/AWS_TCO_Web_Applica

Slide 7

Slide 7 text

Virtualization and the Cloud Running “bare metal” servers is expensive, wasteful, and slow to upgrade. •  Most traditional servers sit underutilized, waiting for traffic spikes and that idling CPU is wasted. •  Adding capacity involves ordering physical servers and going to a physical location to set them up. This takes hours / days. In cloud environments you spin up new virtual instances in minutes. Shared hosting is limited and not scalable. •  Products like Dreamhost Shared Hosting works by putting lots of users on one “bare metal” server on one OS. Users are restricted using the OS user management and customers do not have root access. Security can be a potential issue. In cloud environments you have full root access to your own operating system to setup and manage as you wish. 7 Why is virtualization such a big deal?

Slide 8

Slide 8 text

Why Amazon Cloud? •  Reputation: Biggest and most well- known cloud provider. 8 Why we chose AWS •  Startup Cost: There is no upfront cost. Pay as little as $15/mo to run a “micro” server instance for 1 month. Only run it for 1 hour? Your bill is $0.02. •  Customer base: AWS has an impressive customer base that includes Dropbox, Netflix, Yelp, AirBnB, Reddit, and Pinterest. Amazon.com itself made the switch in 2010. •  Scalability: Scale up when you need it, the moment you need it. Clone or spin up new instances in minutes. Even learn to automate it so instances are created and destroyed based on metrics like overall CPU usage. •  Everything in one place: From servers monitoring to DNS to it’s own CDN, Amazon has setup all the robust services you need to make and scale a great app all in one place.

Slide 9

Slide 9 text

Why Amazon Cloud? •  Ability to mix and match: Not interested in Amazon’s managed database service (RDS)? Setup your own MySQL instance on EC2 and run backups on it yourself. You can pick and choose which AWS services you like and / or stick to the open-source software you’re used to. •  Familiarity: For the most part, there is no “black box magic” with Amazon. These are just virtualized Linux boxes in Data Centers around the globe. If you’re familiar with servers in general then you’re already familiar with much of AWS. There are no new command-line tricks or crazy proprietary workflows. •  Aggressive pricing: There are a lot of new Cloud contenders out there and Amazon is constantly slashing prices to stay competitive. •  Constant innovation: Every few weeks there seems to be a new product or service to make things easier. 9 Why we chose AWS

Slide 10

Slide 10 text

The Cloud Philosophy •  Elasticity: Scale horizontally instead of vertically. •  Parallelization: Strength in numbers. •  Decoupled Components: Every EC2 instance has it’s job. •  Automation: “If you’re SSH’ing in you’re doing it wrong.” Use Puppet, Chef, Salt, etc. •  Design for Failure: “Design for failure and nothing will fail.” 10 Fast and nimble Image  from:  h,p://minibeasts-­‐bees.wikispaces.com/Images+%26+You+Tube+clips+of+bees  

Slide 11

Slide 11 text

Components of AWS 11 •  A Region is essentially a cluster of “Availability Zones”. •  Edge Locations are for Cloudfront CDN. This is the Cloud: 9 Regions worldwide, 4 in North America

Slide 12

Slide 12 text

Components of AWS 12 Availability Zones •  Each Region contains two or more “Availability Zones”. •  AZ’s are distinct locations within a region that are engineered to be isolated from failures in other AZ’s. •  AZ’s have low latency (sub 1-2ms) network connectivity to other AZ’s in the same region. From:  h,p://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-­‐regions-­‐availability-­‐zones.html   •  By load balancing across separate Availability Zones, you can protect your applications from the failure of a single location. •  TIP: It is not generally necessary to load balance across multiple Regions. It requires traveling through the internet and is more technically and financially challenging—only the biggest of the big AWS customers do it.

Slide 13

Slide 13 text

Components of AWS 13 The AWS Dashboard Create and manage virtual servers. Performance Monitoring and alerts.

Slide 14

Slide 14 text

Components of AWS 14 See up to 2 weeks of data on most every aspect of AWS from EC2 to EBS drives. Create alerts on any metric including billing. Using Cloudwatch metrics

Slide 15

Slide 15 text

Components of AWS 15 The AWS Dashboard Create and manage virtual servers. Dirt cheap and Unsinkable. Put all static content in here. Performance Monitoring and alerts.

Slide 16

Slide 16 text

Components of AWS 16 Data in an S3 bucket are stored across a whole Region. Note:  US  Standard  Region  ==  Northern  Virginia  or  Pacific  Northwest  using  network   maps.   •  Store  unlimited   objects  up  to  5TB  in   size.   •  99.999999999%   durability  and   99.99%  availability   of  objects  over  a   given  year.   •  Cheap:  500GB  of   data  stored  in  S3   cost  about  $50/mo   to  store.   •  Even  Twi,er’s  Vine   uses  S3  for  videos.  

Slide 17

Slide 17 text

Components of AWS 17 The AWS Dashboard Create and manage virtual servers. Dirt cheap and Unsinkable. Put all static content in here. But serve it From here Performance Monitoring and alerts.

Slide 18

Slide 18 text

Components of AWS 18 S3 vs. Cloudfront

Slide 19

Slide 19 text

Components of AWS 19 The AWS Dashboard Create and manage virtual servers. Dirt cheap and Unsinkable. Put all static content in here. Performance Monitoring and alerts. But serve it From here. Cheap, low latency, global network of DNS Servers. Give other developers AWS access here. Don’t share logins! Managed DB’s and memory caching. Most autoscale and backup automatically. Useful managed services like Message Queue and Email API. CloudFormation and Cloud-init. We will have to get to that next time…

Slide 20

Slide 20 text

Components of AWS •  EC2: Amazon Elastic Compute Cloud is virtual computing enviornment and service that provides resizable computer capacity. Setup in minutes. Charged by the hour while running. •  AMI: Amazon Machine Image is a special type of pre-configured operating system which is used to create a Virtual Machine within EC2. You can start with community run AMI’s and then make your own. •  EIP: Elastic IP Address is a static IP address you can assign to an EC2 instance so it has a none-changing semi-permanent address. They are free but limited to 10. More potentially available on request to Amazon. •  Security Group: A virtual firewall to specify what ports are accessible on your EC2 instance. 20 EC2 Lingo

Slide 21

Slide 21 text

Components of AWS •  EBS: Elastic Block Store is a persistent storage volume that can be attached to any running EC2 instance. –  Sized from 1 GB to 1 TB. –  Must be placed in the same Availability Zone as the EC2 instance. –  Each storage volume is automatically replicated within the same Availability Zone. –  EC2 instance can have multiple EBS volumes but EBS can not be mounted on more than one EC2 at time. –  Snapshots can be created from any EBS volume and stored in S3 to protect data or to be used as a starting point for a new volume. Snapshots are incremental. –  Like regular hard drive you can attach multiple volumes and stripe your data across them in a RAID configuration for increased I/O. –  You can also enable “provisioned IOPS” for higher performance for a cost. 21 EC2 Lingo

Slide 22

Slide 22 text

Components of AWS •  Instance Storage: Temporary storage that most EC2 instance get for free. If the server reboots the data in Instant Storage stays but if the server is stopped all Instance Storage data is lost. Good for temporary data only. Originated before EBS existed, and only benefit over EBS is that it’s free. 22 EC2 Lingo

Slide 23

Slide 23 text

Setting up Your First EC2 Instance 23 From the main Dashboard click “EC2”, then “Key Pair” at the bottom left.

Slide 24

Slide 24 text

Setting up Your First EC2 Instance 24 We want to use our existing SSH key so click “Import Key Pair”.

Slide 25

Slide 25 text

Setting up Your First EC2 Instance 25 Fill out a Keypair Name and then use terminal to paste your public ssh key. 2   3  paste   Create  a  new  SSH  key  if  you’ve  never  made  one  before:   h,ps://help.github.com/ar

Slide 26

Slide 26 text

Setting up Your First EC2 Instance 26 Your key pair is now created.

Slide 27

Slide 27 text

Setting up Your First EC2 Instance 27 Select “Instances” and then “Launch Instance”. 1   2  

Slide 28

Slide 28 text

Setting up Your First EC2 Instance 28 Click “Continue” on the Classic Wizard. 1  

Slide 29

Slide 29 text

Setting up Your First EC2 Instance 29 Select the Amazon Linux AMI.

Slide 30

Slide 30 text

Setting up Your First EC2 Instance 30 Note the “Instance Type” dropdown and “AZ”. For now go with defaults.

Slide 31

Slide 31 text

Setting up Your First EC2 Instance 31 Advance options screen. Go with defaults.

Slide 32

Slide 32 text

Setting up Your First EC2 Instance 32 You can add EBS or Instance Volumes here. Default is 8GB EBS.

Slide 33

Slide 33 text

Setting up Your First EC2 Instance 33 Give the server a name and Continue.

Slide 34

Slide 34 text

Setting up Your First EC2 Instance 34 Specify your Key Pair and Continue.

Slide 35

Slide 35 text

Setting up Your First EC2 Instance 35 Go with the default security group that allows SSH.

Slide 36

Slide 36 text

Setting up Your First EC2 Instance 36 Confirm all settings and click “Launch”.

Slide 37

Slide 37 text

Setting up Your First EC2 Instance 37 Close confirmation window.

Slide 38

Slide 38 text

Setting up Your First EC2 Instance 38 In about 2 minutes your new instance should be ready.

Slide 39

Slide 39 text

Setting up Your First EC2 Instance 39 SSH into the server to test that your key works. Default user is “ec2-user”. One-time confirmation Success You  could  also  have  create  the  same  instance  by  command-­‐line:    ec2-run-instances -t t1.micro -g quick-start-1 ami-54cf5c3d -v –key "mauvis1"

Slide 40

Slide 40 text

A complete sample web app architecture 40 Coming in part 2: Load balancing across Availability Zones From:  h,p://media.amazonwebservices.com/architecturecenter/AWS_ac_ra_web_01.pdf  

Slide 41

Slide 41 text

Additional Reading •  Amazon Architecture Center: Amazon Architecture Center: http://aws.amazon.com/architecture/ •  Best Practices Whitepaper: http://media.amazonwebservices.com/AWS_Cloud_Best_Practices.pdf •  Operation checklist: http://media.amazonwebservices.com/AWS_Operational_Checklists.pdf •  Whitepaper on Autoscale: http://aws.amazon.com/autoscaling/ •  The Reddit AWS community: http://www.reddit.com/r/aws/ •  Mauvis’s Amazon EC2 Pricing Calculator Google Doc: http://goo.gl/Er90C 41

Slide 42

Slide 42 text

Thanks! Feedback? [email protected] @krunkosaurus http://www.speakerdeck.com/krunkosaurus 42