Slide 1

Slide 1 text

MITT DARKO BRUTAL ENGINEERING Deploying to AWS It’s what business people crave

Slide 2

Slide 2 text

MITT DARKO BRUTAL ENGINEERING What the Heck is it? Really.

Slide 3

Slide 3 text

It’s the systematic abuse of JSON to manipulate resources.

Slide 4

Slide 4 text

Let’s Start Simply.

Slide 5

Slide 5 text

Computers • Almost everything is an EC2 instance • Instances come in many shapes and sizes • They can be ephemeral (instance store) or permanent (elastic block store) • They can be paravirtual (PV) or hardware assisted virtualization (HVM) instances • We will pick our types later

Slide 6

Slide 6 text

Concept: Regions • AWS Regions are isolated from each other and are geographically dispersed. • Since there’s isolation, you have to duplicate infrastructure in different regions if you operate in several regions. • Regions has_many: :availability_zones

Slide 7

Slide 7 text

Concept: Availability Zones • Think of them like data centers with low latency links between each other. Because that’s what they are. • Also think about them like one big data center. Because that’s what the low latency links make it. • Example: You can migrate instances between availability zones.

Slide 8

Slide 8 text

Regions, AZ’s and your App. • Think like Craigslist: Regional Subdomains. • If you see the need, abstract your authentication ASAP.

Slide 9

Slide 9 text

Services • Still, mostly EC2 instances • Again, many shapes and sizes • Services of interest…

Slide 10

Slide 10 text

Route-53: DNS • Latency-based Routing: Route customers to the closest Region • Failover: When everything 500’s, route users somewhere else. • ELB integration. What’s an ELB?

Slide 11

Slide 11 text

ELB: Elastic Load Balancer • Probably the most important concept. • They’re not real. They’re rules on routers that forward traffic to ports. • The rules work within regions, so distribute your instances across many AZ’s. • They include service checks. If your predefined check for say “/login” isn’t working, that node won’t be added to the ELB. Use Route 53 failover for when everything is broken.

Slide 12

Slide 12 text

RDS • Again, EC2 instances. • Again, many shapes and sizes • MySQL, PostgreSQL, Oracle * Edition, MS SQL Server * Edition • For Ruby people, MySQL is the best supported option. Sorry. • Can be setup standalone or Multi-AZ. • Will heal itself if nodes die, thanks Xen/EC2

Slide 13

Slide 13 text

ElastiCache • Again, EC2 instances. • Again, many shapes and sizes • Redis & Memcached. • Redis has a Multi-AZ Option (this is recent) • Will heal itself if nodes die, thanks again Xen/EC2

Slide 14

Slide 14 text

S3/CloudFront • Not EC2 instances. Sorta. • S3: Storage buckets with fun HTTP headers for objects. • CloudFront: Amazon’s Global CDN. Way cheaper than going straight to your bucket. Respects your bucket headers. • If you’re mega-scale, front your whole site through CloudFront and use ESI to handle non-public pages.

Slide 15

Slide 15 text

ESI?

Slide 16

Slide 16 text

Partials on Steroids

Slide 17

Slide 17 text

Automating your Infrastructure • Primary reason to use AWS • It also solves the mother’s day problem. • Use their tools, your own, a third party’s, or a combination of all of those.

Slide 18

Slide 18 text

The Hard Part: Picking Where to Start

Slide 19

Slide 19 text

AWS Tool #1: CloudFormation • It’s a template for your AWS resources. A bunch of JSON defining how everything interconnects and autoscales. • On its own, it is disgusting. It involves weird programming within JSON. I’d never seen John Andrews more angry than when he had to deal with this. • It’s the way to go, unfortunately. There is a way out however. More on that later.

Slide 20

Slide 20 text

ElasticBeanstalk • Completely terrible if you go with this on its own. • You through a wizard that lets you pick really outdated software to roll with and it autoscales your stuff based on load or other user defined events. Yippee! • Fun Fact: This is just easy mode CloudFormation as it just uses it to create templates for your Rails app.

Slide 21

Slide 21 text

OpsWorks • A pretty good option. Based on Chef Solo. • Stacks, layers, instances, apps, and deployments. • Time and/or load based auto scaling. • Metrics on everything. • Use your own Chef recipes • opsworks_custom_env is your friend.

Slide 22

Slide 22 text

OpsWorks, Continued • OpsWorks will put like instances (layers) behind ELB’s if you choose to do so. • Layers can have their own auto-scale rules. All of a sudden have a bigger need for elasticsearch? It’s handled. • Use AWS’s predefined Chef recipes for layers (HAProxy, Rails, etc) or roll your own. You can also add your own recipes to the pre-defined layers. • Con: Building servers and deploying is slow. • Best option for AWS tool only deploys: Use CloudFormation to define your OpsWorks template. Build Staging, QA, etc environments off one template.

Slide 23

Slide 23 text

Third Party Option #1: Asgard • It’s a Grails app from Netflix. • You build an image, it handles launching the instances based off that image and switching your live app to the new build. Rollback is easy. • PROTIP: If you go this route, have your CI build images with Packer upon successful master builds.

Slide 24

Slide 24 text

Third Party Option #2: The First Party • Amazon has a gem for its services. • Use it to interface with any/all AWS services. • It’s not really “ruby”, but it gets the job done.

Slide 25

Slide 25 text

Third Party Option #3: Cloud Management Tools • Scalr, RightScale, Canonical Juju. • Pro: Abstraction of all the concepts in this presentation to work on any cloud provider. • Con: Yet something else to learn.

Slide 26

Slide 26 text

Questions?