cloud patterns - softshake 2013
DESCRIPTION
Architecture constraints and benefits for Cloud applicationsTRANSCRIPT
©2013 CloudBees, Inc. All Rights Reserved
PatternsNicolas De Loof - cloudbees
1
Cloudjeudi 24 octobre 13
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
jeudi 24 octobre 13
©2013 CloudBees, Inc. All Rights Reserved
jeudi 24 octobre 13
©2013 CloudBees, Inc. All Rights Reserved
jeudi 24 octobre 13
©2013 CloudBees, Inc. All Rights Reserved
jeudi 24 octobre 13
©2013 CloudBees, Inc. All Rights Reserved
jeudi 24 octobre 13
©2013 CloudBees, Inc. All Rights Reserved
<me>
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved 5
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Support engineer
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Support engineer
censuré
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Support engineer
censuré
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Maven & Jenkins committer
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
JUG Leader
jeudi 24 octobre 13
©2013 CloudBees, Inc. All Rights Reserved
</me>
jeudi 24 octobre 13
{{ }}
©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
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Cloud
On premiseseasy
May be difficultfor legacy apps
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Cloud
On premiseseasy
May be difficultfor legacy apps
refactor
jeudi 24 octobre 13
{{ }}
©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
{{ }}
©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
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
ScaleOutSc
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Scale up
M1 small
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Scale up
M1 small M1 large
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Scale up
M1 small M1 large M3 double extra large
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Scale up
Then ?M1 small M1 large M3 double extra large
jeudi 24 octobre 13
{{ }}
©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
{{ }}
©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
{{ }}
©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
{{ }}
©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
{{ }}
©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
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
State Less… if you can
be
jeudi 24 octobre 13
{{ }}
©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
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Stateless, really ?
• Beware your frameworks !
Grails
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Stateless, really ?
• Beware your frameworks !
Grailssecurity plugin
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Stateless, really ?
• Beware your frameworks !
Grailssecurity plugin
Spring-security
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights ReservedStateStateless, really ?
• Beware your frameworks !
Grailssecurity plugin
Spring-securityHttpSession
jeudi 24 octobre 13
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
Lock-inPrefer portable API
beware
jeudi 24 octobre 13
{{ }}
©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
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Some Standards
• Java EE• Java Servlet• JVM• LAMP• Node.js• RVM• ..
jeudi 24 octobre 13
©2013 CloudBees, Inc. All Rights Reserved
File SystemBeware
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Cloud uses Schrödinger FS
Looks like it’s alive, but it’s not
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
PaaS != Hosted servers
Your host at this time
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
PaaS != Hosted servers
Your host at this time
Your host after (re)deployment
jeudi 24 octobre 13
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
… aren’tSingletons
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Sample: Quartz Job Scheduler
Job will be triggered on all nodes !
jeudi 24 octobre 13
{{ }}
©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
{{ }}
©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
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
mattersLatency
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
tomcat
app-x
• Inter Continental is common
•EU to us-east-1 latency:120ms
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Measure
• Chrome DEV Tools• Google Pagespeed• YSlow
jeudi 24 octobre 13
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
Migrate to Cloud
jeudi 24 octobre 13
©2013 CloudBees, Inc. All Rights Reserved
Yes!
jeudi 24 octobre 13
©2013 CloudBees, Inc. All Rights Reserved
SOA(the right way)
jeudi 24 octobre 13
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
ConsumeServicesjeudi 24 octobre 13
{{ }}
©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
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
*aaS ecosystem
44
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Private Cloud ?
45
jeudi 24 octobre 13
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
DesignforFailure
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
It May Will fail
jeudi 24 octobre 13
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
CloudSaferis
anyway
jeudi 24 octobre 13
{{ }}
©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
{{ }}
©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
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
forCloudOps
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Infra is managed ... not app
• Need to instrument and monitor
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Ops for Cloud apps
One team, One goal, One platform
jeudi 24 octobre 13
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
ContinuousIntegration
deploymentdelivery
jeudi 24 octobre 13
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
concurrent
0 downtime
deployment
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
0 downtime
http://demo.nicolas.cloudbees.net
rout
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
0 downtime
http://demo.nicolas.cloudbees.net
rout
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
0 downtime
http://demo.nicolas.cloudbees.net
rout
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
0 downtime
http://demo.nicolas.cloudbees.net
rout
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Resources migration
App Vn running
App Vn+1 starting
DB schema Vn
jeudi 24 octobre 13
{{ }}
©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
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
jeudi 24 octobre 13
{{ }}
©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
©2013 CloudBees, Inc. All Rights Reserved
DeploymentIs not an
anymoreevent
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Green / Bluehttp://martinfowler.com/bliki/BlueGreenDeployment.html
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
A/B testing
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Canary testing
jeudi 24 octobre 13
{{ }}
©2013 CloudBees, Inc. All Rights Reserved
Pretotyping
jeudi 24 octobre 13
©2013 CloudBees, Inc. All Rights Reserved
Youthank
jeudi 24 octobre 13