Using Docker to deliver Java Enterprise Applications, one year later…

A presentation at jPrime in May 2016 in Sofia, Bulgaria by Petyo Dimitrov

Slide 1

Slide 1

Using Docker to deliver Java Enterprise Applications one year later… Petyo Dimitrov May 26-27 ‘16, Sofia 26-27/05/2016

Slide 2

Slide 2

Agenda • What problems we had? • Docker introduction • How to “dockerize” a sample application? • Docker technologies • What about VMs? • Lessons learnt…. 26-27/05/2016 2 / 34

Slide 3

Slide 3

problems 26-27/05/2016 3 / 34

Slide 4

Slide 4

inadequate packaging of application artifacts 26-27/05/2016 4 / 34

Slide 5

Slide 5

inconsistencies across environments 26-27/05/2016 5 / 34

Slide 6

Slide 6

high cost supporting multiple static environments 26-27/05/2016 6 / 34

Slide 7

Slide 7

lack of freedom experimenting with new languages, technologies and frameworks 26-27/05/2016 7 / 34

Slide 8

Slide 8

Sea-free analogy 26-27/05/2016 8 / 34

Slide 9

Slide 9

Developers Operations • care about apps • care about containers • put stuff in containers • work with containers • code & data • logging & monitoring • libraries • networking • applications • scaling 26-27/05/2016 9 / 34

Slide 10

Slide 10

High level view of a container • it is like a lightweight Virtual Machine • it provides: • own process space • own network interface • running stuff as root 26-27/05/2016 10 / 34

Slide 11

Slide 11

Low level view of a container • container = “process in a box” • shares kernel with host  boots faster • processes run directly on the host • there is no device emulation • none or little CPU, memory, network and I/O overhead 26-27/05/2016 11 / 34

Slide 12

Slide 12

Fast forward one year 26-27/05/2016 12 / 34

Slide 13

Slide 13

Demonstration https://github.com/petyodimitrov/spring-music.git https://github.com/petyodimitrov/app-setup.git https://github.com/petyodimitrov/ci-setup.git 26-27/05/2016 13 / 34

Slide 14

Slide 14

Used technologies 26-27/05/2016 14 / 34

Slide 15

Slide 15

Runtime view of containers 26-27/05/2016 15 / 34

Slide 16

Slide 16

Standard Java application build 26-27/05/2016 16 / 34

Slide 17

Slide 17

Docker containers build 26-27/05/2016 17 / 34

Slide 18

Slide 18

Adding system testing 26-27/05/2016 18 / 34

Slide 19

Slide 19

Combining all the parts 26-27/05/2016 19 / 34

Slide 20

Slide 20

Demonstration 26-27/05/2016 20 / 34

Slide 21

Slide 21

Docker “ecosystem” 26-27/05/2016 21 / 34

Slide 22

Slide 22

Client-Server model 26-27/05/2016 22 / 34

Slide 23

Slide 23

Docker Engine • runs and commoditizes Linux containers • allows building and sharing images • runs as daemon and has CLI • functionality is exposed via REST API • moves towards standardization (runC, containerd) 26-27/05/2016 23 / 34

Slide 24

Slide 24

Docker Compose • manages a collection of containers • fast, isolated development environments using Docker • define environment via YAML file • quick and easy to start docker-compose up –d 26-27/05/2016 24 / 34

Slide 25

Slide 25

Docker Machine • allows creating Docker hosts on local computer or in cloud providers • automatically creates host, installs Docker and configures the client • offers commands to start, stop, restart and inspect a host docker-machine create —driver virtualbox default 26-27/05/2016 25 / 34

Slide 26

Slide 26

Virtual machines 26-27/05/2016 vs. Containers 26 / 34

Slide 27

Slide 27

Comparison with VMs https://github.com/petyodimitrov/ci-setup.git https://github.com/petyodimitrov/vagrant-setup.git https://github.com/petyodimitrov/vm-container-comparison.git 26-27/05/2016 27 / 34

Slide 28

Slide 28

Application delivery time τ delivery (сек.) τ τ τ τ τ τ virtualization containers package 25,6 29,6 setup 512,8 29,2 startup 163,6 16,4 test 22,8 11 shutdown 23,4 1,4 cleanup 12,4 2,8 760,6 90,4 total 26-27/05/2016 28 / 34

Slide 29

Slide 29

Application delivery time (2) 26-27/05/2016 29 / 34

Slide 30

Slide 30

Performance benchmarks (cpu, memory, net) • CPU performance [MFLOPS]: 2% • Compression speed [MB/s]: 11% average improvement with containers • Memory bandwidth [MB/s]: 3% • Serial/Parallel memory access speed [MB/s]: 19% • Network efficiency [Mbps] & latency [μs]: ? • Privisioning speed [s]: 60 times 26-27/05/2016 30 / 34

Slide 31

Slide 31

Lessons learnt (1) • Decide on a strategy for introducing Docker in the project • Keep and eye for improvements & changes (e.g. networks) • Keep containers simple (i.e. only one/few processes) • Automate, automate, automate … (via docker or other CM tools) • Use initialization & validation scripts (e.g. init, supervisord) 26-27/05/2016 31 / 34

Slide 32

Slide 32

Lessons learnt (2) • Review Dockerfile-s as part of development process (e.g. peer reviews) 14.04.3 FROM alpine-java ubuntu:latest ENV REPO=10.0.1.1:1236 verify checksum RUN apt-get && \ RUN apt-getupdate update–y–y curl RUN apt-get apt-getinstall install curl –y # unnecessary RUN apt-get install wget -y https ${REPO} RUN curl -L http://10.0.1.1:1236/something.jar USER nobody USER ROOT CMD java –jar something.jar add volume 26-27/05/2016 32 / 34

Slide 33

Slide 33

Lessons learnt (3) • Use internal Docker registry for image distribution (unless OSS) • Invest time to setup container monitoring (e.g. logspout + ELK) • Consider using JARs instead of other *ARs • Shared Docker pattern overall works better than DinD • to be continued… 26-27/05/2016 33 / 34

Slide 34

Slide 34

THANK YOU :) You can find me at: petyo.dimitrov@gmail.com Petyo Dimitrov May 26-27 ’16, Sofia 26-27/05/2016