Top Banner
Amazon EC2 in der Praxis Jonathan Weiss
39

Amazon EC2 in der Praxis

Jan 15, 2015

Download

Documents

Jonathan Weiss

Introduction into Amazon EC2 and tools like Chef presented by Jonathan Weiss at OOP 2011 in Munich.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Amazon EC2 in der Praxis

Amazon EC2 in der Praxis

Jonathan Weiss

Page 2: Amazon EC2 in der Praxis

Scalarium

Amazon EC2 Cluster Management

  Auto-Config

  Self-Healing

  Auto-Scaling

  One-click-deployment

www.scalarium.com

2

Page 3: Amazon EC2 in der Praxis

3

Page 4: Amazon EC2 in der Praxis

Amazon Elastic Compute Cloud

Virtual Server via API call

Pay per hour

Different instance types in different regions

4

Page 5: Amazon EC2 in der Praxis

EC2 Features

Spot instances

Elastic IP

Elastic Load Balancing

CloudWatch

Auto Scaling

Virtual Private Cloud 

Elastic Block Storage

5

Page 6: Amazon EC2 in der Praxis

6

Running on EC2 Setting up an app

Page 7: Amazon EC2 in der Praxis

Running on EC2

Steps to complete

  Choose region and availability zone

  Define architecture

  Choose instance types and AMI

  Boot & configure instances

  Deploy application

  …

  Profit

7

Page 8: Amazon EC2 in der Praxis

Region and Availability Zone

Regions   Individual EC2 installations

  Multiple datacenters a.k.a availability zones

  Small differences in pricing

  US-east usually gets features first

Availability Zone

  Datacenter of instances & volumes

  Differently named for different accounts

  Traffic within the same zone is free

  Different Instance type availability

8

Page 9: Amazon EC2 in der Praxis

Existing Availability Zones

US-EAST-1

  us-east-1a

  us-east-1b

  us-east-1c

  us-east-1d

9

US-WEST-1

  us-west-1a

  us-west-1b

EU-WEST-1

  eu-west-1a

  eu-west-1b

AP-SOUTHEAST-1

  ap-southeast-1a

  ap-southeast-1b

Page 10: Amazon EC2 in der Praxis

Single AZ Deployment

Most common and simple setup

Not very different from typical setup

10

Page 11: Amazon EC2 in der Praxis

Multi AZ Deployment

11

Page 12: Amazon EC2 in der Praxis

Architecture

12

Page 13: Amazon EC2 in der Praxis

Architecture

13

Page 14: Amazon EC2 in der Praxis

Architecture

14

Page 15: Amazon EC2 in der Praxis

Elastic IP

  Static, public IP in contrast to instance IP

 Associate to any instance (~15s)

  Paying when not in use

 Use for DNS of load balancer

15

Page 16: Amazon EC2 in der Praxis

Elastic Block Store EBS

 Network based block device: 1GB – 1TB

  Persistent & redundant

  Can be used by one instance at a time

  Incremental Snapshots

  RAID for better performance

16

Page 17: Amazon EC2 in der Praxis

Elastic Load Balancer ELB

 Managed Load Balancer

 Auto-Scales via Round Robin DNS

  Can start/stop instances

  Slower and not as flexible as instance + HAProxy

The only way to scale past 1 Gbit/s!

17

Page 18: Amazon EC2 in der Praxis

Relational Data Store RDS

 Managed MySQL instance

  Choose instance size,

pay ~ 30% premium

 Hot-Failover and read replication

available

 Define a 4h maintenance window

  Better performance than single EBS-backed instance

18

Page 19: Amazon EC2 in der Praxis

Instance Types

19

RAM Cores x ECU Arch Hourly Cost (US-East)

Monthly Cost (US-East)

Micro

Tiny 613 MB Burst 1 x 2 32bit/64bit $0.02 $15

Standard

Small 1.7 GB 1 x 1 32bit $0.085 $62

Large 7.5 GB 2 x 2 64bit $0.34 $248

Extra Large 15 GB 4 x 2 64bit $0.68 $496

High-Memory

Extra Large 17.1 GB 2 x 3.25 64bit $0.50 $366

Double Extra Large 34.2 GB 4 x 3.25 64bit $1.20 $878

Quadruple Extra Large 68.4 GB 8 x 3.25 64bit $2.40 $1756

High-CPU

Medium 1.7 GB 2 x 2.5 32bit $0.17 $124

Extra Large 7 GB 8 x 2.5 64bit $0.68 $496

1 ECU = 1.0 – 1.2 GHz Opteron/Xeon from 2007

Page 20: Amazon EC2 in der Praxis

Recommendation

Start with   Small for load balancer

  Medium for App server

  Large for DB server

  Tiny for monitoring and utility

Grow to

  XL-HighCPU for load balancer

  XL-HighCPU for App server

  XL-HighMemory for DB server

20

Page 21: Amazon EC2 in der Praxis

Reserved Instances

Pay amount upfront and you get:

Hourly price ~ 33%

Guaranteed availability

24/7 instance cost: ~ 55%

Recommended!

21

Page 22: Amazon EC2 in der Praxis

Running on EC2

Steps to complete

 Choose region and availability zone

 Define architecture

 Choose instance types

  Boot & configure instances

  Deploy application

  …

  Profit

22

Page 23: Amazon EC2 in der Praxis

23

Instance Configuration From blank Linux to your Java/Rails/PHP app server

Page 24: Amazon EC2 in der Praxis

Instance Bootstrap

24

2 Approaches

Page 25: Amazon EC2 in der Praxis

Instance Bootstrap

Images

  One image for every server type

  All software pre-installed

  Few moving parts

  Fast boot

25

2 Approaches

Page 26: Amazon EC2 in der Praxis

Instance Bootstrap

Images

  One image for every server type

  All software pre-installed

  Few moving parts

  Fast boot

26

Scripted

  One image to rule them all

  Smallest common denominator

  Acquires configuration on start

  Installs & configures during boot process to fit role

  All parts moving

  Slower boot

2 Approaches

Page 27: Amazon EC2 in der Praxis

Instance Bootstrap

Images

  One image for every server type

  All software pre-installed

  Few moving parts

  Fast boot

27

Scripted

  One image to rule them all

  Smallest common denominator

  Acquires configuration on start

  Installs & configures during boot process to fit role

  All parts moving

  Slow boot

2 Approaches

Page 28: Amazon EC2 in der Praxis

Chef

Open Source Provisioning Tool

  Configures your servers

  Cookbooks & recipes

  Ruby DSL

28

Page 29: Amazon EC2 in der Praxis

Chef

29

Page 30: Amazon EC2 in der Praxis

Chef Solo

30

Page 31: Amazon EC2 in der Praxis

MemcachedSolo

31

Page 32: Amazon EC2 in der Praxis

Chef Solo Run

32

Configuration JSON

Run Chef Solo

Page 33: Amazon EC2 in der Praxis

Deploying

Deploy resource   Compatible with Capistrano layout

  Supports Capistrano hooks via deploy/hook_name.rb

  Async!

33

Page 34: Amazon EC2 in der Praxis

Chef Experiences

Great so far, but

  Not idempotent

  Unintuitive 2 phases

  Documentation could be better

  Example Cookbooks often so so

34

Page 35: Amazon EC2 in der Praxis

Running on EC2

Steps to complete

 Choose region and availability zone

 Define architecture

 Choose instance types

 Boot & configure instances

 Deploy application

  …

  Profit

35

Page 36: Amazon EC2 in der Praxis

The Project

Browser game hosted on EC2

1 million DailyActive Users (DAU)

~ 130 servers

~ 100.000 requests per minute on average

Page 37: Amazon EC2 in der Praxis

Flexibility and Scalability

Page 38: Amazon EC2 in der Praxis

Flexibility and Scalability

Page 39: Amazon EC2 in der Praxis

© Peritor GmbH - Alle Rechte vorbehalten

Peritor GmbH Blücherstr. 22, Hof III Aufgang 6 10961 Berlin

Tel.: +49 (0)30 69 20 09 84 0 Fax: +49 (0)30 69 20 09 84 9

Internet: www.peritor.com E-Mail: [email protected]

Q&A