immutable infrastructure:觀念與實作 (建議)
TRANSCRIPT
#JCConf
William Yeh
#JCConf
William Yeh
immutable infrastructure”
immutable infrastructure”
#JCConf
William Yeh
#JCConf
William Yeh
http://s
end.wtf/
jcconf20
15
#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 2015Universal Scalaby 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 PostaPrincipal 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 PostaPrincipal 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 PostaPrincipal 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
defin
ition
http://www.slideshare.net/jpetazzo/containerization-new-virtualization-docker-separation-operational-concerns
Jérôme Petazzoni
defin
ition
http://www.slideshare.net/jpetazzo/containerization-new-virtualization-docker-separation-operational-concerns
Jérôme Petazzoni
defin
ition
http://www.slideshare.net/jpetazzo/containerization-new-virtualization-docker-separation-operational-concerns
Jérôme Petazzoni
defin
ition
http://www.slideshare.net/jpetazzo/containerization-new-virtualization-docker-separation-operational-concerns
Jérôme Petazzoni
defin
ition
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 allocationprimitivesare required
#JCConf
#JCConf
#JCConf
#JCConf
Golden imagePhenix server
VM image
Golden imagePhenix server
VM imageContainer image
Golden imagePhenix server
VM imageContainer imageUnikernel image
Golden imagePhenix server
VM image Container imageUnikernel 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 imageContainer image
Unikernel image
• Docker ecosystem• docker cli• Docker Hub• CI: Jenkins, Travis CI, CircleCI…
• Pre-Docker tools• Packer: https://www.packer.io/
VM imageContainer image
Unikernel image
VM
VM Docker
Docker
Container per VMDockerHyper: https://hyper.sh/
Container per VMHyper: https://hyper.sh/
Container per VMHyper: https://hyper.sh/
UnikernelBoxfuse: 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.
#JCConf
VM imageContainer image
Unikernel image
new unikernel approach
VM imageContainer image
Unikernel image
new unikernel approach
#JCConf
VM imageContainer imageUnikernel image
VM imageContainer imageUnikernel 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 imageContainer imageUnikernel image
deployment
VM imageContainer imageUnikernel image
DevOps
IT workflow automation
deployment
VM imageContainer imageUnikernel image
DevOps
JCConf 2015,
Abola Lee
IT workflow automation
deployment
VM imageContainer imageUnikernel image
DevOps
JCConf 2015,
Abola Lee
IT workflow automation• Platform-specific tools
• AWS CodeDeploy• Google Cloud Deployment Manager• IBM BlueMix
deployment
VM imageContainer imageUnikernel image
DevOps
JCConf 2015,
Abola Lee
IT workflow automation• Platform-specific tools
• AWS CodeDeploy• Google Cloud Deployment Manager• IBM BlueMix
• Ansible
deployment
VM imageContainer imageUnikernel 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 imageContainer imageUnikernel 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 imageContainer imageUnikernel image
#JCConf
VM imageContainer imageUnikernel image
#JCConf
deployment
VM imageContainer imageUnikernel image
#JCConf
deployment
VM imageContainer imageUnikernel image
#JCConf
#JCConf
William Yeh
http://s
end.wtf/
jcconf20
15