#JCConf


William Yeh
#JCConf


William Yeh
immutable
infrastructure”
immutable
infrastructure”
#JCConf


William Yeh
#JCConf


William Yeh
http://send.wtf/jcconf2015
#JCConf
im‧mutable
im‧mutable
#JCConf
Entropy
Entropy
#JCConf
#JCConf
Q:
7%
A:
lysosomes
#JCConf


#JCConf
#JCConf
DNA
#JCConf
DNA
#JCConf
DNA

lysosomes
#JCConf
DNA

lysosomes
#JCConf
How about computers?
Entropy
?
#JCConf
“HAProxy has been installed on Linux 2.4
systems serving millions of pages every
day, and which have only known one
reboot in 3 years for a complete OS
upgrade.”
Reliability - keeping high-traffic sites online since 2002
“HAProxy has been installed on Linux 2.4
systems serving millions of pages every
day, and which have only known one
reboot in 3 years for a complete OS
upgrade.”
Reliability - keeping high-traffic sites online since 2002
im‧mutable
im‧mutable
im‧mutable
im‧mutable
In OOP and FP, an immutable object is
an object whose state cannot be
modified after it is created.
immutable objects
JCConf 2015

Universal Scala

by Walter Chang
In OOP and FP, an immutable object is
an object whose state cannot be
modified after it is created.
String s = "ABC";
s.toLowerCase();
immutable objects
String s = "ABC";
s.toLowerCase();
Why immutable objects?

• simpler to understand

• inherently thread-safe

• offer higher security than mutable objects.
immutable objects
“How to sort in-place using the merge sort algorithm?”
immutable objects algorithms
• Too complex to be reduced to practical
program.

• Knuth left this as an exercise (Vol 3, 5.2.5).
There do exists in-place merge sort. It
must be implemented carefully.
http://stackoverflow.com/q/2571049/714426
CTAS: Create Table As Select
immutable objects algorithms
• Faster than ALTER TABLE.

• … with some constraints… Google it!
http://stackoverflow.com/q/2571049/714426
databases
DHH (David Heinemeier Hansson)

Creator of Rails.
immutable objects algorithms databases applications
immutable objects algorithms
http://smalltalk.xdite.net/posts/302780-bos-rewrite-from-dhh
databases applications
immutable objects algorithms
http://smalltalk.xdite.net/posts/302780-bos-rewrite-from-dhh
databases applications
immutable
infrastructure
immutable objects algorithms databases applications
immutable
infrastructure
immutable objects algorithms databases applications
Let’s talk about
immutable objects algorithms databases applications Java
hot swap? hot deploy?
immutable objects algorithms databases applications Java
hot swap since JDK 1.4
immutable objects algorithms databases applications Java
hot swap in JRebel
immutable objects algorithms databases applications Java
hot swap in OSGi
immutable objects algorithms databases applications Java
Christian Posta

Principal Middleware Specialist/Architect
at Red Hat, open-source enthusiast,
committer on Apache ActiveMQ, Apache
Camel, Fabric8, HawtIO, blogging,
Family, India Pale Ale.
http://blog.christianposta.com/immutable/immutable-infrastructure-and-the-jvm-part-i/
immutable objects algorithms databases applications Java
• Don’t hotdeploy/redeploy/migrate your
Java services in production at runtime.
Christian Posta

Principal Middleware Specialist/Architect
at Red Hat, open-source enthusiast,
committer on Apache ActiveMQ, Apache
Camel, Fabric8, HawtIO, blogging,
Family, India Pale Ale.
http://blog.christianposta.com/immutable/immutable-infrastructure-and-the-jvm-part-i/
immutable objects algorithms databases applications Java
• Don’t hotdeploy/redeploy/migrate your
Java services in production at runtime.
• Do have a very strong focus on your
delivery pipeline/automation/testing
to quickly make changes to your
system.
Christian Posta

Principal Middleware Specialist/Architect
at Red Hat, open-source enthusiast,
committer on Apache ActiveMQ, Apache
Camel, Fabric8, HawtIO, blogging,
Family, India Pale Ale.
http://blog.christianposta.com/immutable/immutable-infrastructure-and-the-jvm-part-i/
Infra
Infra
immutable
infrastructure”
immutable
infrastructure
definition
http://www.slideshare.net/jpetazzo/containerization-new-virtualization-
docker-separation-operational-concerns
Jérôme Petazzoni
definition
http://www.slideshare.net/jpetazzo/containerization-new-virtualization-
docker-separation-operational-concerns
Jérôme Petazzoni
definition
http://www.slideshare.net/jpetazzo/containerization-new-virtualization-
docker-separation-operational-concerns
Jérôme Petazzoni
definition
http://www.slideshare.net/jpetazzo/containerization-new-virtualization-
docker-separation-operational-concerns
Jérôme Petazzoni
definition
WHY immutable infra?
WHY immutable infra?
• Simplify change management

• hard to keep or restore “desired state” in-place
WHY immutable infra?
• Simplify change management

• hard to keep or restore “desired state” in-place
• Enforce dev/prod parity

• configure & test infra before deployed to
production environment
WHY immutable infra?
• Simplify change management

• hard to keep or restore “desired state” in-place
• Enforce dev/prod parity

• configure & test infra before deployed to
production environment
• Reason about apps at a higher level 

• … than just the deployable packages containing
the code (JAR/WAR/zip/MSI/whatever)
WHY NOT immutable infra?
WHY NOT immutable infra?
• Cost of “out of place” may be too high

• vs
WHY NOT immutable infra?
• Cost of “out of place” may be too high

• vs 

• DevOps maturity level

• Orchestration and

resource allocation

primitives

are required
#JCConf
#JCConf
#JCConf
#JCConf
Golden image

Phenix server
VM image
Golden image

Phenix server
VM image
Container image
Golden image

Phenix server
VM image
Container image
Unikernel image
Golden image

Phenix server
VM image
Container image

Unikernel image
• VM/IaaS provider specific

• VM/IaaS provider agnostic

• Ansible: https://github.com/ansible/ansible
• Packer: https://www.packer.io/

• Otto: https://ottoproject.io/
VM image

Container image
Unikernel image
• Docker ecosystem

• docker cli

• Docker Hub

• CI: Jenkins, Travis CI, CircleCI…

• Pre-Docker tools

• Packer: https://www.packer.io/
VM image

Container image

Unikernel image
VM
VM Docker
Docker
Container per VMDocker
Hyper: https://hyper.sh/
Container per VM
Hyper: https://hyper.sh/
Container per VM
Hyper: https://hyper.sh/
Unikernel
Boxfuse: https://boxfuse.com
Container per VM
Hyper: https://hyper.sh/
Unikernel
Boxfuse: https://boxfuse.com
Unikernels are constructed by
using “library operating
systems,” from which the
developer selects only the
minimal set of services
required for an application to
run.

These sealed, fixed-purpose
images run directly on a
hypervisor without an intervening
guest OS such as Linux.
Unikernel
Boxfuse: https://boxfuse.com
Container per VM
#JCConf
VM image

Container image

Unikernel image
new unikernel approach
VM image

Container image

Unikernel image
new unikernel approach
#JCConf
VM image

Container image

Unikernel image
VM image

Container image

Unikernel image
#JCConf
deployment
deployment
deployment
• Rolling upgrade

• Blue/green deployment

• Canary deployment
deployment
https://www.safaribooksonline.com/
library/view/continuous-delivery/
9780134389363/
deployment
• Cluster management

• Service discovery

• Orchestration
deployment
• Pets vs cattle
• Docker ecosystem is easier…

• Kubernetes

• Mesos

• …
#JCConf
DevOps
deployment
DevOps
deployment
VM image

Container image

Unikernel image
deployment
VM image

Container image

Unikernel image
DevOps
IT workflow automation
deployment
VM image

Container image

Unikernel image
DevOps
JCConf 2015,
Abola Lee
IT workflow automation
deployment
VM image

Container image

Unikernel image
DevOps
JCConf 2015,
Abola Lee
IT workflow automation
• Platform-specific tools

• AWS CodeDeploy

• Google Cloud Deployment Manager

• IBM BlueMix
deployment
VM image

Container image

Unikernel image
DevOps
JCConf 2015,
Abola Lee
IT workflow automation
• Platform-specific tools

• AWS CodeDeploy

• Google Cloud Deployment Manager

• IBM BlueMix
• Ansible
deployment
VM image

Container image

Unikernel image
DevOps
JCConf 2015,
Abola Lee
IT workflow automation
• Platform-specific tools

• AWS CodeDeploy

• Google Cloud Deployment Manager

• IBM BlueMix
• Ansible
• CI SaaS

• Travis CI, CircleCI, etc.
deployment
VM image

Container image

Unikernel image
DevOps
JCConf 2015,
Abola Lee
IT workflow automation
• Platform-specific tools

• AWS CodeDeploy

• Google Cloud Deployment Manager

• IBM BlueMix
• Ansible
• CI SaaS

• Travis CI, CircleCI, etc.
• Atlas (and others from HashiCorp)
Entropy
#JCConf
#JCConf
DNA
#JCConf
DNA
#JCConf
DNA

lysosomes
#JCConf
DNA

lysosomes
#JCConf
VM image

Container image

Unikernel image
#JCConf
VM image

Container image

Unikernel image
#JCConf
deployment
VM image

Container image

Unikernel image
#JCConf
deployment
VM image

Container image

Unikernel image
#JCConf
#JCConf


William Yeh
http://send.wtf/jcconf2015

Immutable infrastructure:觀念與實作 (建議)