cloud patterns

71
Patterns Nicolas De Loof - cloudbees Cloud

Upload: nicolas-de-loof

Post on 09-Jan-2017

1.010 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Cloud patterns

PatternsNicolas De Loof - cloudbees

Cloud

Page 2: Cloud patterns

This talk is a mashup• « PaaS design »

Michael Neale, CloudBees

• « Cloud Best practices »Eric Bottard, VMWare

• my own …

Page 3: Cloud patterns

<me>

Page 4: Cloud patterns

Support engineer

censured

Page 5: Cloud patterns

Maven & Jenkins commiter

Page 6: Cloud patterns

BreizhJUG leader

Page 7: Cloud patterns

</me>

Page 8: Cloud patterns

PaaS

IaaS

End Users

Application Developers

Infrastructure Architects

SaaS

PaaS

IaaS Few world-scaleproviders

A Dozen platforms

Thousands ApplicationsSaaS

Page 9: Cloud patterns
Page 10: Cloud patterns

Cloud

On premiseseasy

May be difficult

for legacy appsrefactor

Page 11: Cloud patterns

Green field applications• Can select modern solutions

most (not all) frameworks are well designed for Cloud

• Started on cloud,discovers and adapts to constraints

mix-it.fr cfp.breizhcamp.org

Page 12: Cloud patterns

« Classic » applications• Not such modern solutions

common frameworks may not fit cloud constraints

• Started on premises, single serverhit cloud constraints

Page 13: Cloud patterns

The Devoxx 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

Page 14: Cloud patterns

ScaleOutSc

Page 15: Cloud patterns

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

M1 small Then ?M1 large M3 double extra large

Page 16: Cloud patterns

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

aka « my personnal laptop »

Page 17: Cloud patterns

Scale out

Adapt resources to actual load

Design for clustering

Pay only for actual use

Page 18: Cloud patterns

What a PaaS actualy does …

M1 large

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

vitru

alisa

tion

Page 19: Cloud patterns

Multi-tenancy• Hardware level (IaaS)• OS level (hypervisor)• OS virtualization (cgroups, LXC)• Middleware ?

Java 9 to be multi-tenant ?

Page 20: Cloud patterns

State Less

… if you can

be

Page 21: Cloud patterns

RESTFul, Stateless• Linear horizontal scaling

But …• Application - User « conversation »

has a state• Stateless apps mostly use caches

then cache needs to be distributed

Page 22: Cloud patterns

StateStateless, really ?

• Beware your frameworks !

Grailssecurity plugin

Spring-securityHttpSession

Page 23: Cloud patterns

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

Page 24: Cloud patterns

Lock-inPrefer portable API

beware

Page 25: Cloud patterns

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

Page 26: Cloud patterns

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

Page 27: Cloud patterns

File System

Beware

Page 28: Cloud patterns

Cloud uses Schrödinger FS

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

Page 29: Cloud patterns

PaaS == pool of servers

Your host at this time

Your host after (re)deployment

Page 30: Cloud patterns

FileSystem is ephemeral(and not distributed)

Use store engine (S3, DB Blob, …)Use fileSystem wrappers(s3fs)

Use ephemeral as a cache

Page 31: Cloud patterns

… aren’tSingletons

Page 32: Cloud patterns

Sample: Quartz Job Scheduler

Job will be triggered on all nodes !

Use Persistent (JDBC) Job Store

Use dedicated cron service

Page 33: Cloud patterns

mattersLatency

Page 34: Cloud patterns
Page 35: Cloud patterns

Measure• Chrome DEV Tools• Google Pagespeed• YSlow

Page 36: Cloud patterns

Improve• Use HTTP cache headers• Use unique path per deployment

hash, or just ?version=• Use a CDN

Page 37: Cloud patterns

Migrate to Cloud

Page 38: Cloud patterns

Yes!

Page 39: Cloud patterns

SOA(the right way)

Page 40: Cloud patterns

Small is beautifull• small, specialized, elastic services• Communicate with REST on HTTP/MQ

Users

frontend

Backend indexer

Page 41: Cloud patterns

ConsumeServices

Page 42: Cloud patterns

*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

Page 43: Cloud patterns

Private cloud is non-sense• Do you produce your own

electricity ?

• Security is about humans, not firewals

Page 44: Cloud patterns

DesignforFailure

Page 45: Cloud patterns

It May Will fail

Page 46: Cloud patterns

Beware resource• Don’t hang the app when resource fails

• Run asynch• Use MQ

Page 47: Cloud patterns

CloudSaferis

anyway

Page 48: Cloud patterns

Some metrics• In 2012,

CloudBees suffered 2 major outages20 then 10 minutes

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

Cloud outages are visible

Page 49: Cloud patterns

Disaster recovery

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

+ your own backup strategy

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

Page 50: Cloud patterns

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

data sync to handle network latency Short TTL DNS

No « turn key » solution

Page 51: Cloud patterns

forCloudOps

Page 52: Cloud patterns

Infra is managed ... not app• Need to instrument and monitor

Page 53: Cloud patterns

Ops for Cloud apps

One team, One goal,

One platform

Page 54: Cloud patterns

Cloud is the best place to embrace DevOps

Traditional CloudEnvironment DEV / INT / PROD identicalDelivery Mostly manual full automation

API basedDEV Process Fire and forget Continuous deliveryTeam Dev vs Ops vs QA DevOps

Page 55: Cloud patterns

ContinuousIntegration

deploymentdelivery

Page 56: Cloud patterns

Continuous …

• Git push• Build• Test

• Git push• Build• Test• Deploy• Production

• Git push• Build• Test• Ready for

production• Production

Integration Deployment Delivery

Page 57: Cloud patterns

Resourcesas

manage

code

Page 58: Cloud patterns

Manage Databaseyou can connect tools to your DB

Page 59: Cloud patterns

But how to …• Replicate environment• Manage DB upgrades• Tag versions (and DB schema)• ..

Page 60: Cloud patterns

All in SCM• Application configuration• Runtime properties• Resources binding• Database scripts…

App deployment is 100% reproductible

Page 61: Cloud patterns

Use agile DB tools

Page 62: Cloud patterns

concurrent

0 downtime

deployment

Page 63: Cloud patterns

0 downtime

http://demo.nicolas.cloudbees.net

router

Page 64: Cloud patterns

Beware resources migration

App Vn running

App Vn+1 starting

DB schema Vn

DB schema Vn+1

Page 65: Cloud patterns

• Vn+1 schema to be Vn compatible• Vn+2 can do some cleanup

i.e. « @deprecated » for DBOr … temporary deploy a « maintenance » page

Page 66: Cloud patterns

DeploymentIs not an

anymoreevent

Page 67: Cloud patterns

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

Page 68: Cloud patterns

A/B testing

Page 69: Cloud patterns

Canary testing

Page 70: Cloud patterns

Pretotyping

Page 71: Cloud patterns

Youthank