Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... ·...

112
Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober 11

Transcript of Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... ·...

Page 1: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Designing Apps for Amazon Web

ServicesMathias Meyer, GOTO Aarhus 2011

Montag, 10. Oktober 11

Page 2: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 3: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Me

♥ infrastructure

♥ code

♥ databases

@roidrage

www.paperplanes.de

Montag, 10. Oktober 11

Page 4: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

The Cloud

Montag, 10. Oktober 11

Unlimited resources, whenever you need them

Page 5: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 6: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 7: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 8: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

10,000 feet

Montag, 10. Oktober 11

Page 9: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Amazon Web Services

Montag, 10. Oktober 11

Page 10: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

EC2

Montag, 10. Oktober 11

Page 11: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

On-demand computing

Montag, 10. Oktober 11

Utility computing

Page 12: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

API

Montag, 10. Oktober 11

It’s not a cloud if it doesn’t have an API.

Page 13: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Pay as you go

Montag, 10. Oktober 11

Page 14: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Multiple regions

Montag, 10. Oktober 11

Geographically distributed, for all web services.US East, West, EU, Singapore, Japan

Page 15: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Multiple datacenters

Montag, 10. Oktober 11

Called availability zones.At least two data centers in each region.Physically separated locations.API endpoint for a region is unspecific for availability zones

Page 16: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Different instance types

Montag, 10. Oktober 11

Page 17: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

High CPUvs.

High memory

Montag, 10. Oktober 11

One CPU core is about the power of a 2007 Xeon processor.

Page 18: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

1.7 GB-

68 GB

Montag, 10. Oktober 11

Page 19: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Elastic Block Store

Montag, 10. Oktober 11

Storage on instances is ephemeral.Goes away when the instance goes away.EBS allows persisting data for longer than an instance’s lifetime.Bound to a data center.

Page 20: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Mount to any instance

Montag, 10. Oktober 11

A big number of block volumes can be mounted to a single instance.

Page 21: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Snapshots

Montag, 10. Oktober 11

A point in time, atomic snapshot of an EBS volume.Not a reliable means of backup, but one means for backups.

Page 22: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

More AWS Products S3

CloudFront

CloudFormation

CloudWatch

RDS

Auto Scaling

SimpleDB

Route 53

Load Balancing

Queue Service

Notification Service

Elastic MapReduce

Montag, 10. Oktober 11

Page 23: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

What’s Scalarium?

Montag, 10. Oktober 11

Page 24: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Automates:

SetupConfigurationOne-Click Deploy

Montag, 10. Oktober 11

Page 25: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

...for EC2

...on EC2

Montag, 10. Oktober 11

Scalarium uses a couple of Amazon’s Web servicesEC2 is the most interesting oneOwn monitoring, because customers like saving money, CloudWatch costs money

Page 26: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Automation

Montag, 10. Oktober 11

Scalarium automates so that customers don’t have to.Most important part about deploying in the cloud.Every manual change is lost when an instance goes down.

Page 27: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

The Dream:

Configure a clusterPush a buttonBoom!

Montag, 10. Oktober 11

Page 28: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Two ways...

Montag, 10. Oktober 11

Page 29: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Create image, boot it.

Montag, 10. Oktober 11

Page 30: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Build once, use forever

Montag, 10. Oktober 11

Point in time snapshot of a system, fully configured.App server, database, web server, etc.

Page 31: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

How do you handle updates?

Montag, 10. Oktober 11

Build a new image, install updates, discard old image.Lather, rinse, repeat, with every update.

Page 32: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Configure from scratch

Montag, 10. Oktober 11

Page 33: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Start with a blank slate.A clean operating system installation.

Page 34: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Use a configuration management tool.Abstracts installation of packages, writing of configuration files, handling file systems, etc.

Page 35: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Configuration+ Cookbooks/Manifests+ Chef/Puppet/etc.= Configured cluster

Montag, 10. Oktober 11

Configuration describes the final result of what the system should look like.

Page 36: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Configuration:

Chef ServerRightScaleJSONScalarium

Montag, 10. Oktober 11

There’s an infinite numbers of infrastructure service providers.Just as many ways to store cluster configuration

Page 37: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

A Web UI to automate and simplify the Amazon APIs and setting up servers/clusters.

Page 38: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

In the beginning...

Montag, 10. Oktober 11

Page 39: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Scalarium

Montag, 10. Oktober 11

Lasted for a few months on just one instance.Instance ran RabbitMQ, CouchDB, Redis, background workers, web and application servers.Bootstrapped startup = start small, iterate quickly.

Page 40: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Eventually became overloaded.

Page 41: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 42: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 43: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Automate,automate,automate!

Montag, 10. Oktober 11

Chef for everything.Yes, our first isntance was not fully automated. Hypocratic.Vagrant is an excellent tool to test locally.Scalarium customers can test their own and our cookbooks locally.Automate setup, configuration, re-configuration of services, everything!

Page 44: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

EC2 is not a traditional datacenter

Montag, 10. Oktober 11

Page 45: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

It doesn’t look like this.

Page 46: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Still looks like this. But it’s transparent to you.No operational access to you.

Page 47: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Multi-tenant

Montag, 10. Oktober 11

Shared resources (CPU, memory, network).You instance likely shares resources with several other EC2 customers on the same physical host.

Page 48: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

High likelihood of failure

Montag, 10. Oktober 11

It’s still hardware that’s running your servers.Hardware fails.

Page 49: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Faulty instances

Montag, 10. Oktober 11

They fail, not all the time, but if you have high turnover scaling up and down, they’ll fail.Discard, boot new instance, done.

Page 50: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Datacenter outage

Montag, 10. Oktober 11

Page 51: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Network partition

Montag, 10. Oktober 11

Page 52: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

More instances=

Higher chanceof failure

Montag, 10. Oktober 11

Page 53: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

MTBF

Montag, 10. Oktober 11

Mean Time Between FailuresOn EC2 as a whole it’s pretty small. Not an important metric.Just because something fails doesn’t mean you have to be affected.

Page 54: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

21/04/2011

Montag, 10. Oktober 11

US-East data centers become unavailable.Cascading failures in EBS storage.Recovery took four days.

Page 55: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

The big chance for nay-sayers and cloud haters.

Page 56: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

The big chance for nay-sayers and cloud haters.

Page 57: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

The big chance for nay-sayers and cloud haters.

Page 58: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

The big chance for nay-sayers and cloud haters.

Page 59: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

The big chance for nay-sayers and cloud haters.

Page 60: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

7/8/2011

Montag, 10. Oktober 11

Downtime in EU data centers.Lightning strike caused power outage.Again, cascading failure in the EBS storage layer.More than three days ‘til full recovery.

Page 61: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 62: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 63: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Failure is a good thing

Montag, 10. Oktober 11

Page 64: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

You can ignore it

Montag, 10. Oktober 11

Page 65: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Learn from it

Montag, 10. Oktober 11

Page 66: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Design for it

Montag, 10. Oktober 11

Page 67: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Don’t fear failure

Montag, 10. Oktober 11

Page 68: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Plan for failure

Montag, 10. Oktober 11

Failure becomes a part of your apps’ lifecycle.Deploying in the cloud has a bigger effect on culture than it does on your application.

Page 69: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Design for resilience

Montag, 10. Oktober 11

In case of failures, you app should handle them gracefully, not breaking along the way entirely.Serve statics instead of failure notices to the user.

Page 70: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Plan for recovery

Montag, 10. Oktober 11

Can you re-deploy your app into a different region quickly?If not, why not?

Page 71: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

MTTR

Montag, 10. Oktober 11

Page 72: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Disaster recovery plan

Montag, 10. Oktober 11

What do you do when your site goes down?What do you do when you need to restore data?Plan, verify, one click.

Page 73: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Multi-datacenterdeployments

Montag, 10. Oktober 11

Deploy App across multiple data centers/availability zones.Make deploying to different data centers part of the deployment process.Staged deployments: new set of instance, flip load balancer.

Page 74: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Replication

Montag, 10. Oktober 11

Storage becomes a key part in handling failure.Everything else is usually much easier to scale and distribute.Replicate data across availability zones, across regions.

Page 75: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Availability zones are geographically distributedReading from in between them means increased latencyReplication ensures data is in multiple geographic locations.Replication allows to recover quickly by moving to different data centers.Not all databases do this well, but they do it

Page 76: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Multi-region deployments

Montag, 10. Oktober 11

If you need to be very highly available.

Page 77: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

$$$

Montag, 10. Oktober 11

Deploying highly distributed is expensive.How distributed is up to your budget.And to how much your availability is worth to your business.

Page 78: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Relax consistency requirements

Montag, 10. Oktober 11

Strong consistency increases need for full availabilityDistribute and partition data, on different instances and different datacenters

Page 79: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Latency

Montag, 10. Oktober 11

Immediately became an issue when we scaled out.Network latency adds to EBS latency and made for higher response times from the database.All network traffic on EC2 is firewalled, even internal traffic.

Page 80: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Keep data local

Montag, 10. Oktober 11

Page 81: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 82: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Keep data in memory

Montag, 10. Oktober 11

Page 83: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Cache is king

Montag, 10. Oktober 11

Disk is expensive because it touches the network.

Page 84: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Use RAIDs for EBS

Montag, 10. Oktober 11

Increased performance, better network utilizationEBS performance is okay, but not great. Don’t expect SATA or SAS like performance.RAID 0, 5 or 10.EBS is redundant, but extra reduncany with striping doesn’t hurt. More likely recovery when one EBS volume fails.RAIDs won’t save you from EBS unavailability.

Page 85: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Use local storage

Montag, 10. Oktober 11

Don’t use EBS at all.Local storage requires redundancy.Instance storage is lost when the instance is lost.RAID across local storage.More reliable in terms of I/O than EBS.Services that uses local storage where mostly unaffected by the EC2 outages.

Page 86: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Use bigger instances

Montag, 10. Oktober 11

The bigger your instance the less shared it is on the host.Bigger instances have higher I/O throughput.

Page 87: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

What would I do differently?

Montag, 10. Oktober 11

Page 88: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Small services

Montag, 10. Oktober 11

Small services can run independent of each other.Small services are easy to deploy, easy to reconfigure (Chef).Don’t have to know about all the other services upfront, leave that to CM tools.Layered system with small services allows failure handling on every layer.Failure in one layer doesn’t have to drag down the rest.

Page 89: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Frontend vs. Small APIs

Montag, 10. Oktober 11

Page 90: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Fail fast

Montag, 10. Oktober 11

When components fail, don’t block waiting for them. Timeout quickly.Circuit breaker: track failures and fail operations immediately if you know they’re likely to fail. recover when it’s safe again.

Page 91: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Retry

Montag, 10. Oktober 11

Retry with an exponential backoff. Assume failure always.

Page 92: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Don’t justassume failure

Montag, 10. Oktober 11

Page 93: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Test failure

Montag, 10. Oktober 11

Shut off instances randomly, see what happens.Turn on the firewall, adds network timeouts, see what happens.The cloud makes it so easy to bring up test environments, and to move resources quickly when necessary.

Page 94: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Netflix’ Chaos Monkey randomly kills instances.

Page 95: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

“Think about your software running.”

Theo Schlossnagle, OmniTI

Montag, 10. Oktober 11

Page 96: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Understand your code’s breaking points

Montag, 10. Oktober 11

Use patterns like circuit breakers and bulkheads to reduce failure pointsThink about outcome and implications, not just features.Understand your code’s breaking points and how they handle unavailability, timeouts, and the like.

All these are so much more likely in a cloud environment.

Page 97: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Isn’t all that what you do at large scale?

Montag, 10. Oktober 11

It’s what you do at any scale where availability is a factor.

Page 98: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Cloud==

Large scale

Montag, 10. Oktober 11

Page 99: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

You’re a part of it

Montag, 10. Oktober 11

Prepare for the worst, plan for the worst.The cloud made failure at a large scale obvious even when you’re working at a small scale.

Page 100: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Scalarium today

Montag, 10. Oktober 11

Page 101: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Scalariumruns on

Scalarium

Montag, 10. Oktober 11

Page 102: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Easy to boot up somewhere else, switch over DNS, done.

Page 103: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 104: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Montag, 10. Oktober 11

Page 105: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Lack of visibility

Montag, 10. Oktober 11

Takes up to an hour still to acknowledge problems.Amazon is not good at admitting failure happens a lot on EC2.Not enough education on how to build apps for EC2 and their web services, especially how to deal with failure.

Page 106: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Don’t fall for SLAs

Montag, 10. Oktober 11

Page 107: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Amazon only handles infrastructure

Montag, 10. Oktober 11

Page 108: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

How you build on itis up to you

Montag, 10. Oktober 11

Page 109: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Fun fact

Montag, 10. Oktober 11

Page 110: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

amazon.comis served off EC2

Montag, 10. Oktober 11

Since 21/10/2010.Yes, they were down too, at least during the EU outage.

Page 111: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

It’s not the cloud that matters, it’s how

you use it.

Montag, 10. Oktober 11

EC2 doesn’t make everything harder, quite the opposite, it makes things easier:Adding capacity, automation, responding to failures.

Page 112: Designing Apps for Amazon Web Servicesjaoo.dk/dl/goto-aarhus-2011/slides/MathiasMeyer... · Designing Apps for Amazon Web Services Mathias Meyer, GOTO Aarhus 2011 Montag, 10. Oktober

Thank you!

Montag, 10. Oktober 11