cloud patterns - softshake 2013

93
©2013 CloudBees, Inc. All Rights Reserved Patterns Nicolas De Loof - cloudbees 1 Cloud jeudi 24 octobre 13

Upload: nicolas-de-loof

Post on 14-Jan-2015

1.321 views

Category:

Education


3 download

DESCRIPTION

Architecture constraints and benefits for Cloud applications

TRANSCRIPT

Page 1: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

PatternsNicolas De Loof - cloudbees

1

Cloudjeudi 24 octobre 13

Page 2: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

This talk is a mashup

• « PaaS design »Michael Neale, CloudBees

• « Cloud Best practices »Eric Bottard, VMWare

• my own …

jeudi 24 octobre 13

Page 3: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

jeudi 24 octobre 13

Page 4: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

jeudi 24 octobre 13

Page 5: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

jeudi 24 octobre 13

Page 6: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

jeudi 24 octobre 13

Page 7: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

jeudi 24 octobre 13

Page 8: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

<me>

jeudi 24 octobre 13

Page 9: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved 5

jeudi 24 octobre 13

Page 10: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Support engineer

jeudi 24 octobre 13

Page 11: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Support engineer

censuré

jeudi 24 octobre 13

Page 12: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Support engineer

censuré

jeudi 24 octobre 13

Page 13: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Maven & Jenkins committer

jeudi 24 octobre 13

Page 14: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

JUG Leader

jeudi 24 octobre 13

Page 15: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

</me>

jeudi 24 octobre 13

Page 16: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

End Users

Application Developers

Infrastructure Architects

Few world-scaleproviders

A Dozen platforms

Thousands Applications

PaaS

IaaS

SaaS

PaaS

IaaS

SaaS

jeudi 24 octobre 13

Page 17: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Cloud

On premiseseasy

May be difficultfor legacy apps

jeudi 24 octobre 13

Page 18: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Cloud

On premiseseasy

May be difficultfor legacy apps

refactor

jeudi 24 octobre 13

Page 19: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Green field applications

• Can select modern solutionsmost (not all) frameworks are well designed for Cloud

• Started on cloud, discovers and adapts to constraints

à devoxx.be 2013

jeudi 24 octobre 13

Page 20: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

« Classic » applications

• Not such modern solutionscommon frameworks may not fit cloud constraints

• Started on premises, single server, hit cloud constraints

jeudi 24 octobre 13

Page 21: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

The Devoxx 2012 apps

• Call for Paper and Registration• High traffic two months a year• Self hosted (parleys.com infra)

moved to CloudBees PaaS

• Wicket, Spring, MySQLNo hype, like 99% java applications

jeudi 24 octobre 13

Page 22: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

ScaleOutSc

jeudi 24 octobre 13

Page 23: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Scale up

M1 small

jeudi 24 octobre 13

Page 24: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Scale up

M1 small M1 large

jeudi 24 octobre 13

Page 25: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Scale up

M1 small M1 large M3 double extra large

jeudi 24 octobre 13

Page 26: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Scale up

Then ?M1 small M1 large M3 double extra large

jeudi 24 octobre 13

Page 27: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Scale up

• Still possible, but will hit a limit• Not optimal

Then ?M1 small M1 large M3 double extra large

jeudi 24 octobre 13

Page 28: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

M1 extra large

• 64 bits• 15 Gb memory• 4 Vcore, 2 cpu unit (~2.5Gh)• 1.6 Tb HD

aka « my personnal laptop »

jeudi 24 octobre 13

Page 29: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Scale out

Adapt resources to actual load

Design for clustering

Pay only for actual use

jeudi 24 octobre 13

Page 30: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

What a PaaS actually does …

M1 large

• slice a server into cells• Multi-tenant app hosting

vitr

ua

lisa

tion

jeudi 24 octobre 13

Page 31: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

What a PaaS actually does …

M1 large

• slice a server into cells• Multi-tenant app hosting

vitr

ua

lisa

tion

jeudi 24 octobre 13

Page 32: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Multi-tenancy

• Hardware level (IaaS)

• OS level (hypervisor)

• OS virtualization (cgroups, LXC)

• Middleware ? Java 9 to be multi-tenant ?

jeudi 24 octobre 13

Page 33: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

State Less… if you can

be

jeudi 24 octobre 13

Page 34: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

RESTFul, Stateless

• Linear horizontal scaling

But …• Application - User « conversation » has a state• Stateless apps mostly use caches

then cache needs to be distributed

jeudi 24 octobre 13

Page 35: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Stateless, really ?

• Beware your frameworks !

Grails

jeudi 24 octobre 13

Page 36: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Stateless, really ?

• Beware your frameworks !

Grailssecurity plugin

jeudi 24 octobre 13

Page 37: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Stateless, really ?

• Beware your frameworks !

Grailssecurity plugin

Spring-security

jeudi 24 octobre 13

Page 38: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights ReservedStateStateless, really ?

• Beware your frameworks !

Grailssecurity plugin

Spring-securityHttpSession

jeudi 24 octobre 13

Page 39: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Does Stateless really exist ?

• Client side state with browser cookies à higher network traffic, security

• Use http session (servlet frameworks)à memcache session replicationà sticky session

• Use a central service (DB)à SPoF, DB scalability

jeudi 24 octobre 13

Page 40: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

Lock-inPrefer portable API

beware

jeudi 24 octobre 13

Page 41: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Standards

• Use standard, portable APIs (aka Java EE, the good parts)

• Set runtime configuration via env variables / system properties

• at least use some abstraction to insulate vendor-specific code

jeudi 24 octobre 13

Page 42: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Some Standards

• Java EE• Java Servlet• JVM• LAMP• Node.js• RVM• ..

jeudi 24 octobre 13

Page 43: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

File SystemBeware

jeudi 24 octobre 13

Page 44: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Cloud uses Schrödinger FS

Looks like it’s alive, but it’s not

jeudi 24 octobre 13

Page 45: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

PaaS != Hosted servers

Your host at this time

jeudi 24 octobre 13

Page 46: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

PaaS != Hosted servers

Your host at this time

Your host after (re)deployment

jeudi 24 octobre 13

Page 47: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

FileSystem is ephemeral(and not distributed)

File system is not persistent, neither distributed

Use storage engine à la Amazon S3 (or DB BLOB) ... and see local FileSystem as a convenient cache

jeudi 24 octobre 13

Page 48: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

… aren’tSingletons

jeudi 24 octobre 13

Page 49: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Sample: Quartz Job Scheduler

Job will be triggered on all nodes !

jeudi 24 octobre 13

Page 50: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Sample: Quartz Job Scheduler

Job will be triggered on all nodes !

à Use Persistent (JDBC) Job Store

jeudi 24 octobre 13

Page 51: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Sample: Quartz Job Scheduler

Job will be triggered on all nodes !

à Use Persistent (JDBC) Job Store

jeudi 24 octobre 13

Page 52: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Sample: Quartz Job Scheduler

Job will be triggered on all nodes !

à Use Persistent (JDBC) Job Store

à Use dedicated cron service

jeudi 24 octobre 13

Page 53: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

mattersLatency

jeudi 24 octobre 13

Page 54: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

tomcat

app-x

• Inter Continental is common

•EU to us-east-1 latency:120ms

jeudi 24 octobre 13

Page 55: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Measure

• Chrome DEV Tools• Google Pagespeed• YSlow

jeudi 24 octobre 13

Page 56: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Improve

• Use HTTP cache headers• Use unique path per deployment

hash, or just ?version=• Use a CDN

jeudi 24 octobre 13

Page 57: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

Migrate to Cloud

jeudi 24 octobre 13

Page 58: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

Yes!

jeudi 24 octobre 13

Page 59: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

SOA(the right way)

jeudi 24 octobre 13

Page 60: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Small is beautifull

• small, specialized, elastic services• Communicate with REST on HTTP (sync)

MQ (async)

Users

frontend

Backend indexer

jeudi 24 octobre 13

Page 61: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

ConsumeServicesjeudi 24 octobre 13

Page 62: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

*aaS ecosystem

• *aaS is about service, not software

• Integrate services, don’t try to setup your own infrastructure

• AWS, the place to be for *aaS

jeudi 24 octobre 13

Page 63: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

*aaS ecosystem

44

jeudi 24 octobre 13

Page 64: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Private Cloud ?

45

jeudi 24 octobre 13

Page 65: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Private cloud is non-sense

• Do you produce your own electricity ?

• Security is about humans, not firewalls

jeudi 24 octobre 13

Page 66: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

DesignforFailure

jeudi 24 octobre 13

Page 67: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

It May Will fail

jeudi 24 octobre 13

Page 68: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Beware resource

• Don’t hang the app when resource fails

• Be asynchronous and fault tolerant

• Use Messaging

jeudi 24 octobre 13

Page 69: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

CloudSaferis

anyway

jeudi 24 octobre 13

Page 70: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Some metrics• In 2012,

CloudBees suffered 2 major outages20 then 10 minutes

à 99,99% (What’s your actual availability rate ?)

Cloud outages are visiblejeudi 24 octobre 13

Page 71: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Disaster recovery

• All deployed artifact à S3• DB on EBS, then daily à S3

+ your own backup strategy

http://wiki.cloudbees.com/bin/view/Documentation/BackupPolicies

jeudi 24 octobre 13

Page 72: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Need more ?• Multi-zone High-Availability• Mutli-region redundency

à data sync to handle network latencyà Short TTL DNS

No « turn key » solution

jeudi 24 octobre 13

Page 73: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

forCloudOps

jeudi 24 octobre 13

Page 74: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Infra is managed ... not app

• Need to instrument and monitor

jeudi 24 octobre 13

Page 75: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Ops for Cloud apps

One team, One goal, One platform

jeudi 24 octobre 13

Page 76: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Cloud is the best place to embrace DevOps

Traditional Cloud

Environment DEV / INT / PROD identical

Delivery Mostly manual full automationAPI based

DEV Process Fire and forget Continuous delivery

Team Dev vs Ops vs QA DevOps

jeudi 24 octobre 13

Page 77: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

ContinuousIntegration

deploymentdelivery

jeudi 24 octobre 13

Page 78: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Continuous …

• Git push• Build• Test

•Git push•Build•Test•Deploy•Production

•Git push•Build•Test•Ready for production•Production

Integration Deployment Delivery

jeudi 24 octobre 13

Page 79: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

concurrent

0 downtime

deployment

jeudi 24 octobre 13

Page 80: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

0 downtime

http://demo.nicolas.cloudbees.net

rout

jeudi 24 octobre 13

Page 81: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

0 downtime

http://demo.nicolas.cloudbees.net

rout

jeudi 24 octobre 13

Page 82: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

0 downtime

http://demo.nicolas.cloudbees.net

rout

jeudi 24 octobre 13

Page 83: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

0 downtime

http://demo.nicolas.cloudbees.net

rout

jeudi 24 octobre 13

Page 84: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Resources migration

App Vn running

App Vn+1 starting

DB schema Vn

jeudi 24 octobre 13

Page 85: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Resources migration

App Vn running

App Vn+1 starting

DB schema Vn

DB schema Vn+1

jeudi 24 octobre 13

Page 86: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

jeudi 24 octobre 13

Page 87: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

• Vn+1 schema to be Vn compatible• Vn+2 can do some cleanup i.e. « @deprecated » for DB

Or … temporary deploy a « maintenance » page

jeudi 24 octobre 13

Page 88: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

DeploymentIs not an

anymoreevent

jeudi 24 octobre 13

Page 89: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Green / Bluehttp://martinfowler.com/bliki/BlueGreenDeployment.html

jeudi 24 octobre 13

Page 90: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

A/B testing

jeudi 24 octobre 13

Page 91: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Canary testing

jeudi 24 octobre 13

Page 92: Cloud patterns - softshake 2013

{{ }}

©2013 CloudBees, Inc. All Rights Reserved

Pretotyping

jeudi 24 octobre 13

Page 93: Cloud patterns - softshake 2013

©2013 CloudBees, Inc. All Rights Reserved

Youthank

jeudi 24 octobre 13