A talk given to JCConf 2015 on 2015/12/05.
在程式設計領域,“immutable objects” 是相當重要的設計模式。同樣的,在虛擬化及雲端時代,“immutable infrastructure” 也成為新一代的顯學。在資源及流程的充分配合下,這將會大大簡化系統的複雜度,穩定性也會大大提升。
本演講將會從觀念出發,並佐以部份實作建議,讓大家有足夠資訊來評估此架構的好處。
Video: https://youtu.be/9j008nd6-A4
36. “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
37. “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
42. 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
43. 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
44. String s = "ABC";
s.toLowerCase();
Why immutable objects?
• simpler to understand
• inherently thread-safe
• offer higher security than mutable objects.
immutable objects
45. “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
46. CTAS: Create Table As Select
immutable objects algorithms
• Faster than ALTER TABLE.
• … with some constraints… Google it!
http://stackoverflow.com/q/2571049/714426
databases
56. 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/
57. 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/
58. 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/
67. WHY immutable infra?
• Simplify change management
• hard to keep or restore “desired state” in-place
68. 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
69. 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)
71. WHY NOT immutable infra?
• Cost of “out of place” may be too high
• vs
72. WHY NOT immutable infra?
• Cost of “out of place” may be too high
• vs
• DevOps maturity level
• Orchestration and
resource allocation
primitives
are required
92. 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.