SlideShare a Scribd company logo
1 of 61
Immutable
infrastructure
with Docker and
containers
1 / 58
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/immutable-servers-docker
Presented at QCon New York
www.qconnewyork.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Who am I?
Jérôme Petazzoni (@jpetazzo)
French software engineer living in California
Joined Docker (dotCloud) more than 4 years ago
(I was at Docker before it was cool!)
I have built and scaled the dotCloud PaaS
I learned a few things about running containers
(in production)
2 / 58
Outline
What is immutable infrastructure?
What are its pros and cons?
How can it be implemented with containers?
Also: demos!
3 / 58
Immutable
infrastructure
(a.k.a. immutable servers,
phoenix servers, etc.)
4 / 58
Rule 1: never change what's on a server
Don't install new packages
Don't upgrade existing ones
Don't remove or downgrade them
(Even for security vulnerabilities!)
Don't edit configuration files
Don't update your app code
(Even for small or urgent fixes!)
5 / 58
Rule 2: if tempted to change something...
See Rule 1
(OK, we will see an exception later.)
6 / 58
How do we upgrade?
Create new server from scratch
Apply deployment process*
(scripts, configuration management...)
(Optional: test the new server)
Replace old server with new server
Keep old server around, just in case
* Configuration management helps, but is not mandatory here.
7 / 58
WHY?!?
8 / 58
Avoid drift
9 / 58
Avoid drift
10 / 58
Avoid drift
Drift = differences between servers
(when they are supposed to be identical)
Caused by:
provisioning servers at different times
any manual operation
Consequences:
seemingly random failures
same code, different behavior
gets worse with time
11 / 58
Coping with drift
Careful replication of manual operations doesn't scale
(and is error-prone)
Automation seems simple at first,
but has to deal with many edge cases
Configuration management helps,
but only deals with what you've defined
12 / 58
Automation fails
"Let's use parallel-ssh!" (Or your favorite tool)
What if some servers...
are unreachable
become unreachable during the process
are being provisioned at the same time
What if one of those services is (partially) down?
distro package repositories
code or artifact repositories
13 / 58
Config management fails
package{"openssl":ensure=>"installed"}
14 / 58
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
15 / 58
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
16 / 58
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
Something went wrong, abort, abort!
17 / 58
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
Something went wrong, abort, abort!
package{"openssl":ensure=>"installed"}
18 / 58
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
Something went wrong, abort, abort!
package{"openssl":ensure=>"installed"}
We didn't roll back to whatever-we-had!
19 / 58
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
Something went wrong, abort, abort!
package{"openssl":ensure=>"installed"}
We didn't roll back to whatever-we-had!
package{"openssl":ensure=>"1.0.1f"}
20 / 58
Config management fails
package{"openssl":ensure=>"installed"}
A wild OpenSSL vulnerability appears!
package{"openssl":ensure=>"1.0.1g"}
Something went wrong, abort, abort!
package{"openssl":ensure=>"installed"}
We didn't roll back to whatever-we-had!
package{"openssl":ensure=>"1.0.1f"}
This should do the trick. (Hopefully.)
21 / 58
More nightmares
package{"openssl":ensure=>"1.0.1f"}
22 / 58
More nightmares
package{"openssl":ensure=>"1.0.1f"}
Package not found on the repos.
23 / 58
More nightmares
package{"openssl":ensure=>"1.0.1f"}
Package not found on the repos.
"Well, actually" we want an older version.
24 / 58
More nightmares
package{"openssl":ensure=>"1.0.1f"}
Package not found on the repos.
"Well, actually" we want an older version.
Package even less likely to be found on the repos.
25 / 58
More nightmares
package{"openssl":ensure=>"1.0.1f"}
Package not found on the repos.
"Well, actually" we want an older version.
Package even less likely to be found on the repos.
"Well, actually" we were using 0.9.8xxx.
When we requested 1.0.1g we upgraded the whole distro.
26 / 58
More nightmares
package{"openssl":ensure=>"1.0.1f"}
Package not found on the repos.
"Well, actually" we want an older version.
Package even less likely to be found on the repos.
"Well, actually" we were using 0.9.8xxx.
When we requested 1.0.1g we upgraded the whole distro.
(╯°□°)╯︵ ┻━┻)
27 / 58
With immutable servers
We still have the old server
Just put it back into service
(while we figure out the OpenSSL upgrade!)
Also works for any kind of upgrade
that needs to be rolled back
Alright, we have easy rollbacks.
But how does that help with drift?
28 / 58
"Trash your servers and burn your code"
(Chad Fowler)
Reprovision your servers regularly
(from scratch)
Ensures that you're always using recent packages
Any manual deviation gets fixed automatically
29 / 58
Improvement: golden image
Create a server from scratch
Apply deployment process
Snapshot this server (create an image)
(Optional: create a test server and validate it)
Create multiple identical servers from the image
Avoids uncertainties in the deployment process:
unreachable packages repositories etc.
Allows to keep (for cheap) past versions around.
30 / 58
Downsides
(and how to cope)
31 / 58
Problem: small changes are cumbersome
E.g. one line of CSS.
Before: manual change, validate, replicate
(a few minutes)
After: manual change, validate, ...
create new golden image from scratch
(one hour)
provision new servers from image
(a few minutes)
switch old/new servers
decommission old servers after a while
32 / 58
Solution: automation
All those operations have to happen
But everything after the "validate" step
should be automated
The clock time will still be 1+ hour
The user time will be a few minutes
(just like before)
Note: intermediary golden images can help
(provision from checkpoint instead of from scratch)
33 / 58
Problem: debugging is harder
E.g. troubleshoot network issues.
Before:
install tcpdump
fiddle with iptables
accumulate logs and packet captures locally
After:
install tcpdu-oops, the server was re-imaged
fiddle with ipta-oops, ...
logs and traces have to be shipped out
34 / 58
Solution 1: drift and self-destruct
Tag a given machine to prevent its "re-imaging"
Schedule it for self-destruct after e.g. 1 week
(shutdown+10000)
That machine is allowed to drift
(you can install your tools on it,
leave logs and traces locally...)
If you need more time, reschedule the self-destruct
35 / 58
Solution 1: drift and self-destruct
Tag a given machine to prevent its "re-imaging"
Schedule it for self-destruct after e.g. 1 week
(shutdown+10000)
That machine is allowed to drift
(you can install your tools on it,
leave logs and traces locally...)
If you need more time, reschedule the self-destruct
If you find yourself setting up a cron job to reschedule the self-
destruct, you're doing it wrong!
36 / 58
Solution 2: bundle the tools
Install tcpdumpand friends in the golden image
Enable traffic capture with feature switch
(Alternate solution: statistical sampling)
Automate shipping of logs and traces
It's more work in the beginning, but pays in the long run.
37 / 58
Problem: storing data
Databases and anything stateful!
Before: just store it locally
After: need to persist it somehow
38 / 58
Solution 1: not my problem
"Often you can pass the buck to a service which someone else
maintains, like Amazon's RDS database service."
(Kief Morris)
Easy!
But what if:
there is no such service
I can't use it for $REASONS?
39 / 58
Solution 2: state = files
All you need is a mechanism to store files externally.
NAS/SAN (on-prem)
EBS, EFS (AWS)
Ceph, Gluster... (anywhere)
But it's extra work, expensive, and/or slower.
40 / 58
Solution 3: ?
41 / 58
Solution 3: ?
SPOILER ALERT
42 / 58
Solution 3
43 / 58
Immutable
containers
44 / 58
Let's review our process
Create image:
from scratch
(can take an hour or more)
from checkpoint
(takes a few minutes, more complex)
Deploy it N times
(takes a few minutes)
How do we do that with containers?
45 / 58
Building container images
We get the best of both worlds:
from scratch
(clean rebuilds without side-effects)
incremental
(fast rebuilds when changes are minor)
Why and how?
container snapshots are cheap
(seconds versus minutes)
simple DSL to break down the build into steps
(each step = one command = one snapshot)
46 / 58
FROMdebian:jessie
MAINTAINERJessicaFrazelle<jess@docker.com>
#Installdependencies
RUNapt-getupdate&&apt-getinstall-y
build-essential
… 
--no-install-recommends
#Installnode
RUNcurl-sLhttps://deb.nodesource.com/setup|bash-
RUNapt-getinstall-ynodejs
#Cloneatom
RUNgitclonehttps://github.com/atom/atom/src
WORKDIR/src
RUNgitfetch&&gitcheckout
$(gitdescribe--tags
`gitrev-list--tags--max-count=1`)
RUNscript/build&&script/gruntinstall
#Autorunatom
CMD/usr/local/bin/atom--foreground
47 / 58
What happens during the first build?
FROMdebian
RUNapt-getxxx
COPY./src
RUN/src/build
Create a container from debianbase image
Execute apt-getxxxin this container, take a snapshot
Create a container from this snapshot
Copy source files into /src, take a snapshot
Create a container from this snapshot
Execute /src/buildin this container, take a snapshot
The final snapshot is our built image.
48 / 58
What happens during subsequent builds?
Before executing each step:
check if we already executed the same step before
(and have a snapshot of its result)
if we do, use the snapshot and continue
otherwise, execute the step normally
(and snapshot the result)
As a result, we zoom through the build process,
until we hit a step that has changed
The end result is the same as a full clean build,
but much faster
49 / 58
Demo
50 / 58
Running container images
On physical or virtual machines
Run multiple containers per machine
Upgrading is faster
(doesn't have to wait for IaaS VM to come up)
Can reuse local data (Docker concept: "volumes")
Solves the stateful service problem
51 / 58
Demo
52 / 58
Bonus
Containers can share:
directories (e.g.: logs)
network stack (e.g.: traffic analysis)
... and more!
Logging, backups, metrics collection, troubleshooting...
can be done from "sidekick" containers.
53 / 58
Demo
54 / 58
Other niceties
Containers filesystem can be made read-only
enforces immutability
exception for data volumes (with noexec)
easier security audit
Cheaper
consolidation
save a few ¢ or $ per server per deploy
(great if your IAAS bills by the hour)
55 / 58
Conclusions
56 / 58
Immutable containers
All the advantages of immutable servers
(avoid drift, reliable rollbacks...)
Build in seconds instead of minutes/hours
Faster, simpler deployment
Deal with stateful services
Bonus: cheaper, safer, cleaner
57 / 58
Thanks!
Questions?
@jpetazzo
@docker
58 / 58
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations/
immutable-servers-docker

More Related Content

What's hot

Unix Automation using centralized configuration management tool
Unix Automation using centralized configuration management toolUnix Automation using centralized configuration management tool
Unix Automation using centralized configuration management tool
Torrid Networks Private Limited
 

What's hot (20)

Pro Puppet
Pro PuppetPro Puppet
Pro Puppet
 
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special EditionIntroduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
 
Unix Automation using centralized configuration management tool
Unix Automation using centralized configuration management toolUnix Automation using centralized configuration management tool
Unix Automation using centralized configuration management tool
 
Internship presentation
Internship presentationInternship presentation
Internship presentation
 
Hyper v r2 deep dive
Hyper v r2 deep diveHyper v r2 deep dive
Hyper v r2 deep dive
 
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
 
LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013
 
Docker, Linux Containers, and Security: Does It Add Up?
Docker, Linux Containers, and Security: Does It Add Up?Docker, Linux Containers, and Security: Does It Add Up?
Docker, Linux Containers, and Security: Does It Add Up?
 
Mercurial Distributed Version Control
Mercurial Distributed Version ControlMercurial Distributed Version Control
Mercurial Distributed Version Control
 
Node.js at Joyent: Engineering for Production
Node.js at Joyent: Engineering for ProductionNode.js at Joyent: Engineering for Production
Node.js at Joyent: Engineering for Production
 
Latency vs everything
Latency vs everythingLatency vs everything
Latency vs everything
 
Puppet for SysAdmins
Puppet for SysAdminsPuppet for SysAdmins
Puppet for SysAdmins
 
.ppt
.ppt.ppt
.ppt
 
Cassandra and docker
Cassandra and dockerCassandra and docker
Cassandra and docker
 
Designing and coding Series 40 Java apps for high performance
Designing and coding Series 40 Java apps for high performanceDesigning and coding Series 40 Java apps for high performance
Designing and coding Series 40 Java apps for high performance
 
GopherCon 2017 - Writing Networking Clients in Go: The Design & Implementati...
GopherCon 2017 -  Writing Networking Clients in Go: The Design & Implementati...GopherCon 2017 -  Writing Networking Clients in Go: The Design & Implementati...
GopherCon 2017 - Writing Networking Clients in Go: The Design & Implementati...
 
Chef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & ChefChef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & Chef
 
Scalable Systems Management with Puppet
Scalable Systems Management with PuppetScalable Systems Management with Puppet
Scalable Systems Management with Puppet
 
Novices guide to docker
Novices guide to dockerNovices guide to docker
Novices guide to docker
 
Solving Real World Production Problems with Docker
Solving Real World Production Problems with DockerSolving Real World Production Problems with Docker
Solving Real World Production Problems with Docker
 

Similar to Easier, Better, Faster, Safer Deployment with Docker and Immutable Containers

LXC Containers and AUFs
LXC Containers and AUFsLXC Containers and AUFs
LXC Containers and AUFs
Docker, Inc.
 
One Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONEOne Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONE
Software AG
 
Scale11x lxc talk
Scale11x lxc talkScale11x lxc talk
Scale11x lxc talk
dotCloud
 
Advanced off heap ipc
Advanced off heap ipcAdvanced off heap ipc
Advanced off heap ipc
Peter Lawrey
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operations
grim_radical
 

Similar to Easier, Better, Faster, Safer Deployment with Docker and Immutable Containers (20)

Infrastructure as Code, Theory Crash Course
Infrastructure as Code, Theory Crash CourseInfrastructure as Code, Theory Crash Course
Infrastructure as Code, Theory Crash Course
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetes
 
Capistrano, Puppet, and Chef
Capistrano, Puppet, and ChefCapistrano, Puppet, and Chef
Capistrano, Puppet, and Chef
 
Docker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xDocker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12x
 
LXC Containers and AUFs
LXC Containers and AUFsLXC Containers and AUFs
LXC Containers and AUFs
 
Lightweight Virtualization: LXC containers & AUFS
Lightweight Virtualization: LXC containers & AUFSLightweight Virtualization: LXC containers & AUFS
Lightweight Virtualization: LXC containers & AUFS
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
 
Building a Gateway Server
Building a Gateway ServerBuilding a Gateway Server
Building a Gateway Server
 
One Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONEOne Path to a Successful Implementation of NaturalONE
One Path to a Successful Implementation of NaturalONE
 
Scale11x lxc talk
Scale11x lxc talkScale11x lxc talk
Scale11x lxc talk
 
Advanced off heap ipc
Advanced off heap ipcAdvanced off heap ipc
Advanced off heap ipc
 
LibOS as a regression test framework for Linux networking #netdev1.1
LibOS as a regression test framework for Linux networking #netdev1.1LibOS as a regression test framework for Linux networking #netdev1.1
LibOS as a regression test framework for Linux networking #netdev1.1
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operations
 
It's Time to Debloat the Cloud with Unikraft
It's Time to Debloat the Cloud with UnikraftIt's Time to Debloat the Cloud with Unikraft
It's Time to Debloat the Cloud with Unikraft
 
Sensepost assessment automation
Sensepost assessment automationSensepost assessment automation
Sensepost assessment automation
 
Interview questions
Interview questionsInterview questions
Interview questions
 
Tomcat from a cluster to the cloud on RP3
Tomcat from a cluster to the cloud on RP3Tomcat from a cluster to the cloud on RP3
Tomcat from a cluster to the cloud on RP3
 
Containers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific TrioContainers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific Trio
 
Cfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymoreCfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymore
 
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
 

More from C4Media

More from C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Easier, Better, Faster, Safer Deployment with Docker and Immutable Containers

  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /immutable-servers-docker
  • 3. Presented at QCon New York www.qconnewyork.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 4. Who am I? Jérôme Petazzoni (@jpetazzo) French software engineer living in California Joined Docker (dotCloud) more than 4 years ago (I was at Docker before it was cool!) I have built and scaled the dotCloud PaaS I learned a few things about running containers (in production) 2 / 58
  • 5. Outline What is immutable infrastructure? What are its pros and cons? How can it be implemented with containers? Also: demos! 3 / 58
  • 7. Rule 1: never change what's on a server Don't install new packages Don't upgrade existing ones Don't remove or downgrade them (Even for security vulnerabilities!) Don't edit configuration files Don't update your app code (Even for small or urgent fixes!) 5 / 58
  • 8. Rule 2: if tempted to change something... See Rule 1 (OK, we will see an exception later.) 6 / 58
  • 9. How do we upgrade? Create new server from scratch Apply deployment process* (scripts, configuration management...) (Optional: test the new server) Replace old server with new server Keep old server around, just in case * Configuration management helps, but is not mandatory here. 7 / 58
  • 13. Avoid drift Drift = differences between servers (when they are supposed to be identical) Caused by: provisioning servers at different times any manual operation Consequences: seemingly random failures same code, different behavior gets worse with time 11 / 58
  • 14. Coping with drift Careful replication of manual operations doesn't scale (and is error-prone) Automation seems simple at first, but has to deal with many edge cases Configuration management helps, but only deals with what you've defined 12 / 58
  • 15. Automation fails "Let's use parallel-ssh!" (Or your favorite tool) What if some servers... are unreachable become unreachable during the process are being provisioned at the same time What if one of those services is (partially) down? distro package repositories code or artifact repositories 13 / 58
  • 17. Config management fails package{"openssl":ensure=>"installed"} A wild OpenSSL vulnerability appears! 15 / 58
  • 18. Config management fails package{"openssl":ensure=>"installed"} A wild OpenSSL vulnerability appears! package{"openssl":ensure=>"1.0.1g"} 16 / 58
  • 19. Config management fails package{"openssl":ensure=>"installed"} A wild OpenSSL vulnerability appears! package{"openssl":ensure=>"1.0.1g"} Something went wrong, abort, abort! 17 / 58
  • 20. Config management fails package{"openssl":ensure=>"installed"} A wild OpenSSL vulnerability appears! package{"openssl":ensure=>"1.0.1g"} Something went wrong, abort, abort! package{"openssl":ensure=>"installed"} 18 / 58
  • 21. Config management fails package{"openssl":ensure=>"installed"} A wild OpenSSL vulnerability appears! package{"openssl":ensure=>"1.0.1g"} Something went wrong, abort, abort! package{"openssl":ensure=>"installed"} We didn't roll back to whatever-we-had! 19 / 58
  • 22. Config management fails package{"openssl":ensure=>"installed"} A wild OpenSSL vulnerability appears! package{"openssl":ensure=>"1.0.1g"} Something went wrong, abort, abort! package{"openssl":ensure=>"installed"} We didn't roll back to whatever-we-had! package{"openssl":ensure=>"1.0.1f"} 20 / 58
  • 23. Config management fails package{"openssl":ensure=>"installed"} A wild OpenSSL vulnerability appears! package{"openssl":ensure=>"1.0.1g"} Something went wrong, abort, abort! package{"openssl":ensure=>"installed"} We didn't roll back to whatever-we-had! package{"openssl":ensure=>"1.0.1f"} This should do the trick. (Hopefully.) 21 / 58
  • 26. More nightmares package{"openssl":ensure=>"1.0.1f"} Package not found on the repos. "Well, actually" we want an older version. 24 / 58
  • 27. More nightmares package{"openssl":ensure=>"1.0.1f"} Package not found on the repos. "Well, actually" we want an older version. Package even less likely to be found on the repos. 25 / 58
  • 28. More nightmares package{"openssl":ensure=>"1.0.1f"} Package not found on the repos. "Well, actually" we want an older version. Package even less likely to be found on the repos. "Well, actually" we were using 0.9.8xxx. When we requested 1.0.1g we upgraded the whole distro. 26 / 58
  • 29. More nightmares package{"openssl":ensure=>"1.0.1f"} Package not found on the repos. "Well, actually" we want an older version. Package even less likely to be found on the repos. "Well, actually" we were using 0.9.8xxx. When we requested 1.0.1g we upgraded the whole distro. (╯°□°)╯︵ ┻━┻) 27 / 58
  • 30. With immutable servers We still have the old server Just put it back into service (while we figure out the OpenSSL upgrade!) Also works for any kind of upgrade that needs to be rolled back Alright, we have easy rollbacks. But how does that help with drift? 28 / 58
  • 31. "Trash your servers and burn your code" (Chad Fowler) Reprovision your servers regularly (from scratch) Ensures that you're always using recent packages Any manual deviation gets fixed automatically 29 / 58
  • 32. Improvement: golden image Create a server from scratch Apply deployment process Snapshot this server (create an image) (Optional: create a test server and validate it) Create multiple identical servers from the image Avoids uncertainties in the deployment process: unreachable packages repositories etc. Allows to keep (for cheap) past versions around. 30 / 58
  • 33. Downsides (and how to cope) 31 / 58
  • 34. Problem: small changes are cumbersome E.g. one line of CSS. Before: manual change, validate, replicate (a few minutes) After: manual change, validate, ... create new golden image from scratch (one hour) provision new servers from image (a few minutes) switch old/new servers decommission old servers after a while 32 / 58
  • 35. Solution: automation All those operations have to happen But everything after the "validate" step should be automated The clock time will still be 1+ hour The user time will be a few minutes (just like before) Note: intermediary golden images can help (provision from checkpoint instead of from scratch) 33 / 58
  • 36. Problem: debugging is harder E.g. troubleshoot network issues. Before: install tcpdump fiddle with iptables accumulate logs and packet captures locally After: install tcpdu-oops, the server was re-imaged fiddle with ipta-oops, ... logs and traces have to be shipped out 34 / 58
  • 37. Solution 1: drift and self-destruct Tag a given machine to prevent its "re-imaging" Schedule it for self-destruct after e.g. 1 week (shutdown+10000) That machine is allowed to drift (you can install your tools on it, leave logs and traces locally...) If you need more time, reschedule the self-destruct 35 / 58
  • 38. Solution 1: drift and self-destruct Tag a given machine to prevent its "re-imaging" Schedule it for self-destruct after e.g. 1 week (shutdown+10000) That machine is allowed to drift (you can install your tools on it, leave logs and traces locally...) If you need more time, reschedule the self-destruct If you find yourself setting up a cron job to reschedule the self- destruct, you're doing it wrong! 36 / 58
  • 39. Solution 2: bundle the tools Install tcpdumpand friends in the golden image Enable traffic capture with feature switch (Alternate solution: statistical sampling) Automate shipping of logs and traces It's more work in the beginning, but pays in the long run. 37 / 58
  • 40. Problem: storing data Databases and anything stateful! Before: just store it locally After: need to persist it somehow 38 / 58
  • 41. Solution 1: not my problem "Often you can pass the buck to a service which someone else maintains, like Amazon's RDS database service." (Kief Morris) Easy! But what if: there is no such service I can't use it for $REASONS? 39 / 58
  • 42. Solution 2: state = files All you need is a mechanism to store files externally. NAS/SAN (on-prem) EBS, EFS (AWS) Ceph, Gluster... (anywhere) But it's extra work, expensive, and/or slower. 40 / 58
  • 44. Solution 3: ? SPOILER ALERT 42 / 58
  • 47. Let's review our process Create image: from scratch (can take an hour or more) from checkpoint (takes a few minutes, more complex) Deploy it N times (takes a few minutes) How do we do that with containers? 45 / 58
  • 48. Building container images We get the best of both worlds: from scratch (clean rebuilds without side-effects) incremental (fast rebuilds when changes are minor) Why and how? container snapshots are cheap (seconds versus minutes) simple DSL to break down the build into steps (each step = one command = one snapshot) 46 / 58
  • 50. What happens during the first build? FROMdebian RUNapt-getxxx COPY./src RUN/src/build Create a container from debianbase image Execute apt-getxxxin this container, take a snapshot Create a container from this snapshot Copy source files into /src, take a snapshot Create a container from this snapshot Execute /src/buildin this container, take a snapshot The final snapshot is our built image. 48 / 58
  • 51. What happens during subsequent builds? Before executing each step: check if we already executed the same step before (and have a snapshot of its result) if we do, use the snapshot and continue otherwise, execute the step normally (and snapshot the result) As a result, we zoom through the build process, until we hit a step that has changed The end result is the same as a full clean build, but much faster 49 / 58
  • 53. Running container images On physical or virtual machines Run multiple containers per machine Upgrading is faster (doesn't have to wait for IaaS VM to come up) Can reuse local data (Docker concept: "volumes") Solves the stateful service problem 51 / 58
  • 55. Bonus Containers can share: directories (e.g.: logs) network stack (e.g.: traffic analysis) ... and more! Logging, backups, metrics collection, troubleshooting... can be done from "sidekick" containers. 53 / 58
  • 57. Other niceties Containers filesystem can be made read-only enforces immutability exception for data volumes (with noexec) easier security audit Cheaper consolidation save a few ¢ or $ per server per deploy (great if your IAAS bills by the hour) 55 / 58
  • 59. Immutable containers All the advantages of immutable servers (avoid drift, reliable rollbacks...) Build in seconds instead of minutes/hours Faster, simpler deployment Deal with stateful services Bonus: cheaper, safer, cleaner 57 / 58
  • 61. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/ immutable-servers-docker