SlideShare una empresa de Scribd logo
1 de 60
1
Why you’re going to FAIL running Java on docker!
bit.ly/javadockerfail
@burrsutter @rafabene
@burrsutter
Change History
0.1 - JBCNConf.com 2017 - Barcelona
0.2 - JavaOne 2017 - San Francisco
0.3 - JavaDay UA 2017 - Kiev
Big Wins for Developers
● Highly Portable Packaging solution - for microservices, web apps
● Lightweight, Encapsulated OS abstraction - carry your OS with you
● Getting Started (docker run -it centos/wildfly) Instantly
● Dev Environments that more closely match Prod Environments
● Dev Environments that match OTHER Dev Environments (no more...but it
works on my machine)
● No more waiting 3+ weeks for a VM to be provisioned by Ops just so you
can run a series of tests
Linux Container
@burrsutter
@burrsutter
Virtualization vs Containers
Server Machine
Host Operating System
Hypervisor
Guest
OS
Guest
OS
Guest
OS
Bins
Libs
Bins
Libs
Bins
Libs
App 1 App 2 App 3
Server Machine
Host Operating System
Bins
Libs
Bins
Libs
App 1 App 2 App 3
Docker
● Shared bins/libs and Host Operating
System make containers lighter
● You can run multiple versions of app
dependencies (Java 6 and 7)
● “Golden Image” deployment model
● Process isolation
Pros vs Cons
Pros:
● Docker containers start very fast, take less memory
● Super easy to try out a new technology (e.g docker pull centos)
● Supports the “immutable image” deployment model
● It caches layers to make builds faster
Cons:
● It is not a VM - it is a process running within the Host OS, do not assume
you can run any flavor of container OS on any host OS
● It is not perfectly portable - you will eventually wish to get out of
boot2docker-vm into a real Linux VM - one that more closely matches your
production environment
● Lineage of docker images at Docker Hub is unknown
History of Containers
2000
2010
2005
2015
2000:
JAILS ADDED
TO FREEBSD
2006:
GENERIC PROCESS
CONTAINERS
2008:
KERNEL AND USER
NAMESPACES
2014:
GOOGLE
KUBERNETES
2008:
LINUX CONTAINER
PROJECT (LXC)
2015:
STANDARDS VIA
OCI AND CNCF
2013:
RED HAT
ENTERPRISE LINUX
2013:
DOTCLOUD
BECOMES DOCKER
2007:
GPC RENAMED
CONTROL GROUPS
2003:
SELINUX ADDED TO
LINUX MAINLINE
2015:
RHT CONTAINER
PLATFORM
2001:
LINUX -VSERVER
PROJECT
2013:
DOTCLOUD PYCON
LIGHTNING TALK
2005:
FULL RELEASE OF
SOLARIS ZONES
History of Java
Java 1.0.2 - 30 May 1996
J2EE 1.2 - 12 Dec 1999
https://en.wikipedia.org/wiki/Java_EE_version_history#J2EE_1.2_.28December_12.2C_1999.29
https://en.wikipedia.org/wiki/Java_version_history
A Challenge
Server Hardware
Operating System
Application Server
.war or .ear
Java Virtual Machine
Custom Configuration
Linux Kernel Version & Distribution
Java 1.6.6_45 or Java 1.7.0_67
Weblogic 10.x.y, Tomcat 6.x.y, JBoss EAP 6.x.y
JDBC driver, datasource, JMS queue, users
Have you ever had “/” vs “” break your app? Or perhaps needed a unique version of a
JDBC driver? Or had a datasource with a slightly misspelled JNDI name? Or received a
patch for the JVM or app server that broke your code?
Containerize
Your
App
Email
MyApp.war has been tested with the following
On my Windows 7 desktop
JDK 1.8.43
Wildfly 9
Configuration:
Datasource: MySQLDS
Tested with: mysql-connector-java-5.1.31-bin.jar
Production Environment
Red Hat Enterprise Linux 6.2
JRE 1.7.3
WebSphere 8.5.5
Oracle 9
Dockerfile
Container Guest OS
Java App Server
custom configuration
FROM centos/wildfly
COPY standalone.xml /opt/wildfly/standalone/configuration/
COPY mysql-connector-java-5.1.31-bin.jar /opt/wildfly/standalone/deployments/
COPY mysql-sample-ds.xml /opt/wildfly/standalone/deployments/
COPY myapp/target/your.war /opt/wildfly/standalone/deployments/
your.war
dependencies
Note: There are better ways to handle Java apps, this is for illustration purposes
@burrsutter
Behind the Scenes
Cgroups and Namespaces
Cgroups
- cpu (cpu shares)
- cpuacct
- cpuset (limit processes to a CPU)
- memory (swap, dirty pages)
- blkio (throttle reads/writes)
- devices
- net_prio (packet class and priority)
- freezer
Namespaces
- pid (processes)
- net (network interfaces, routing)
- ipc (system V ipc)
- mnt (mount points, filesystems)
- uts (hostname)
- user (UIDs)
/sys/fs/cgroup/memory
cgroup.clone_children memory.kmem.tcp.limit_in_bytes memory.move_charge_at_immigrate
cgroup.event_control memory.kmem.tcp.max_usage_in_bytes memory.oom_control
cgroup.procs memory.kmem.tcp.usage_in_bytes memory.pressure_level
memory.failcnt memory.kmem.usage_in_bytes memory.soft_limit_in_bytes
memory.force_empty memory.limit_in_bytes memory.stat
memory.kmem.failcnt memory.max_usage_in_bytes memory.swappiness
memory.kmem.limit_in_bytes memory.memsw.failcnt memory.usage_in_bytes
memory.kmem.max_usage_in_bytes memory.memsw.limit_in_bytes memory.use_hierarchy
memory.kmem.slabinfo memory.memsw.max_usage_in_bytes notify_on_release
memory.kmem.tcp.failcnt memory.memsw.usage_in_bytes tasks
@burrsutter
DevOps Challenges for Multiple Containers
▪ How to scale?
▪ How to avoid port conflicts?
▪ How to manage them on
multiple hosts?
▪ What happens if a host has
trouble?
▪ How to keep them running?
▪ How to update them?
▪ Where are my containers?
Node
Node Node
Node Node
Logger
Node
@burrsutter
▪ Greek for “Helmsman,” also the root of the
word “Governor” (from latin: gubernator)
▪ Container orchestrator
▪ Supports multiple cloud and bare-metal
environments
▪ Inspired by Google’s experience with containers
▪ Open source, written in Go
▪ Manage applications, not machines
Meet Kubernetes
SCM
(Git/Svn)
Master
API Server
Service Layer
VirtualPhysical Private Public
Persistent
Storage
Node Node
Logger
Node
Node Node Node
Dev
Ops
CI/CD
Automation
Routing Layer
Registry
SDN Overlay Network
Controllers
- Scheduler
- Deployments
- Services
- Builds
- Routes
- DeploymentConfigs
Kubernetes
OpenShift
- Builds
- ImageStreams
SCM
(Git/Svn)
Master
API Server
Service Layer
VirtualPhysical Private Public
Persistent
Storage
Node Node
Logger
Node
Node Node Node
Dev
Ops
CI/CD
Automation
Routing Layer
Registry
SDN Overlay Network
Controllers
- Scheduler
- Deployments
- Services
- Builds
- Routes
- DeploymentConfigs
Kubernetes
OpenShift
- Builds
- ImageStreams
SCM
(Git/Svn)
Master
API Server
Service Layer
VirtualPhysical Private Public
Persistent
Storage
Node Node
Logger
Node
Node Node Node
Dev
Ops
CI/CD
Automation
Routing Layer
Registry
SDN Overlay Network
Controllers
- Scheduler
- Deployments
- Services
- Builds
- Routes
- DeploymentConfigs
Kubernetes
OpenShift
- Builds
- ImageStreams
@burrsutter
Java
Why Fail?
8GB
4 cores
64GB
16 cores
Developer Workstation
Production Server
@burrsutter
System.out.println("Memory: " +
Runtime.getRuntime().maxMemory()/1024/1024);
System.out.println("CPUs: " +
Runtime.getRuntime().availableProcessors());
Why does Java Fail?
It sees ALL the HOST resources, it is blind to cgroups by default
Note: free also fails
https://fabiokung.com/2014/03/13/memory-inside-linux-containers/
@burrsutter
@burrsutter
Tomcat
https://github.com/apache/tomcat/blob/trunk/java/org/apache/catalina/core/ContainerBase.java#L304
https://github.com/apache/tomcat/blob/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java#L138
https://github.com/apache/tomcat/blob/trunk/java/org/apache/tomcat/websocket/AsyncChannelGroupUtil.java#L85
https://github.com/apache/tomcat/blob/trunk/java/org/apache/catalina/manager/StatusTransformer.java#L224
Wildfly
https://github.com/wildfly/wildfly-common/blob/master/src/main/java/org/wildfly/common/cpu/ProcessorInfo.java#L61
Vert.x
https://github.com/eclipse/vert.x/blob/master/src/main/java/io/vertx/core/VertxOptions.java#L41
Who uses those APIs?
Tomcat, Wildfly, Vert.x
@burrsutter
Memory (max heap defaults to ¼ of available memory)
JIT Optimizations
Mode: Client or Server
Thread Management
Garbage Collector
Do NOT just “java -jar myVertxApp.jar” nor “java -jar mySpringBootApp.jar”
Do try “java -XX:+PrintFlagsFinal -XX:+PrintGCDetails $JAVA_OPTIONS -jar myApp.jar”
JVM Ergonomics
https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/ergonomics.html
@burrsutter
Memory
@burrsutter
Heap (-Xms -Xmx)
------------------------------
Native JRE
Perm (-XX:MaxPermSize), Java8 Meta (-XX:SurvivorRatio, -XX:MaxNewSize, -XX:NewRatio)
JIT Bytecode
JNI
NIO
Threads (defaults to 512K to 1024K depending on platform)
Tip: Either -Xmx at 50% of container constrained memory or
-XX:MaxRam=500m - your heap will be approximately 250mb *
JVM Memory: Heap is about 50%
@burrsutter
@burrsutter
https://hub.docker.com/r/fabric8/java-jboss-openjdk8-jdk/
https://github.com/fabric8io-images/java/blob/master/images/jboss/openjdk8/jdk/container-limits
max_memory() {
# High number which is the max limit until which memory is supposed to be
# unbounded.
local max_mem_unbounded="$(cat /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes)"
local mem_file="/sys/fs/cgroup/memory/memory.limit_in_bytes"
if [ -r "${mem_file}" ]; then
local max_mem="$(cat ${mem_file})"
if [ ${max_mem} -lt ${max_mem_unbounded} ]; then
echo "${max_mem}"
fi
fi
}
Workaround
docker pull fabric8/java-jboss-openjdk8-jdk
@burrsutter
Heap Patched: Java 8u131, included in Java 9
https://bugs.openjdk.java.net/browse/JDK-8170888
@burrsutter
Try it yourself
Just need Docker for Mac or Windows
docker run -m 100MB openjdk:8u121 java -XshowSettings:vm -version
vs
docker run -m 100MB openjdk:8u131 java -XX:+UnlockExperimentalVMOptions
-XX:+UseCGroupMemoryLimitForHeap -XshowSettings:vm -version
UseCGroupMemoryLimitForHeap tells the JVM to look to the cgroup’s value
for memory in /sys/fs/cgroup/memory/memory.limit_in_bytes
@burrsutter
Cores
@burrsutter
docker run --cpus="1.5" -m 400M openjdk:8u131
*docker run --cpu-quota=150000 --cpu-period=100000 -m 400M
openjdk:8u131
docker run --cpu-shares=1536 -m 400M openjdk:8u131
**docker run --cpuset-cpus=0,2 -m 400M openjdk:8u131
Docker CPU Settings
https://docs.docker.com/engine/admin/resource_constra
ints/#configure-the-default-cfs-scheduler
* Kubernetes uses this model
** JVM properly calculates availableProcessors()
@burrsutter
docker run -it --cpus="2" -m 200M java
java -XX:ParallelGCThreads=2
-XX:ConcGCThreads=2
-Djava.util.concurrent.ForkJoinPool.common.parallelism=2
-XX:MaxRam=200m
// Half a core cpu-quota / cpu-period
docker run -it --cpu-quota=50000 --cpu-period=100000 -m 200M openjdk:8u131
java -XX:+UseSerialGC -Xmx=100m
Note: Set Max heap (-Xmx) to about 50% of total container memory
Note: UseSerialGC when core count is below 2
Docker CPU Mapped to Java
Some “rules of thumb”
@burrsutter
CPU Set Patched
https://bugs.openjdk.java.net/browse/JDK-6515172
@burrsutter
Demo Boom
https://github.com/burrsutter/javadockerfail
Demo Script
https://docs.google.com/document/d/1Td_nnjk12Miq6SpRs3RysDZbpQUjpxXk_p0J526VhcE/edit?usp=sharing
@burrsutter
Base Docker Image
FROM fabric8/java-jboss-openjdk8-jdk:1.2.7
Maven Plugin:
- Docker builds leveraging base image
- Deploys to Kubernetes and OpenShift easily
https://fabric8.io/gitbook/mavenPlugin.html
mvn io.fabric8:fabric8-maven-plugin:3.3.5:setup
mvn fabric8:deploy
Hot Tips
https://hub.docker.com/r/fabric8/java-jboss-openjdk8-jdk/
@burrsutter
More and More Resources
https://developers.redhat.com/products/cdk/download/
https://github.com/burrsutter/javadockerfail
https://developers.redhat.com/blog/2017/03/14/java-inside-docker/
https://developers.redhat.com/blog/2017/04/04/openjdk-and-containers/
https://dzone.com/articles/running-a-jvm-in-a-container-without-getting-kille
https://github.com/redhat-developer-demos/java-container
https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how-
pods-with-resource-limits-are-run
https://github.com/fabric8io-images/java/tree/master/images/jboss/openjdk8/jdk
https://github.com/fabric8io-images/java/blob/master/images/jboss/openjdk8/jdk/container-limits
http://cs.oswego.edu/pipermail/concurrency-interest/2016-March/015014.html
bit.ly/javadockerfail
52
Why you’re going to FAIL running Java on docker!
bit.ly/javadockerfail
@burrsutter @rafabene
@burrsutter
Previously Used Slides
Creative Commons/Flikr, SF History Center, SF Public Library, GG Bridge 1935-1936 at
http://www.onlyinyourstate.com/northern-california/san-francisco/life-san-francisco-1935/
Creative Commons/Flikr, SF History Center, SF Public Library, GG & Bay Bridges 1935 at
http://www.onlyinyourstate.com/northern-california/san-francisco/life-san-francisco-1935/
Creative Commons Found SF Historical Archive, GG & Bay Bridges, at
http://www.onlyinyourstate.com/northern-california/san-francisco/life-san-francisco-1935/
Creative Commons Photo ‘For Bankrupt Hanjin, Costs and Containers Pile Up’ at
https://www.workboat.com/news/bluewater/hanjin-costs-containers-pile-up-us-ports/
Wikimedia Commons ‘Container Port & Toxic Fire San Francisco’ at
https://commons.wikimedia.org/wiki/File:Containter_port_and_toxic_fire,_San_Francisco.jpg

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Docker.io
Docker.ioDocker.io
Docker.io
 
[En] IPVS for Docker Containers
[En] IPVS for Docker Containers[En] IPVS for Docker Containers
[En] IPVS for Docker Containers
 
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
 
Scaling Development Environments with Docker
Scaling Development Environments with DockerScaling Development Environments with Docker
Scaling Development Environments with Docker
 
Going Reactive with Java
Going Reactive with JavaGoing Reactive with Java
Going Reactive with Java
 
[2018.10.19] Andrew Kong - Tunnel without tunnel (Seminar at OpenStack Korea ...
[2018.10.19] Andrew Kong - Tunnel without tunnel (Seminar at OpenStack Korea ...[2018.10.19] Andrew Kong - Tunnel without tunnel (Seminar at OpenStack Korea ...
[2018.10.19] Andrew Kong - Tunnel without tunnel (Seminar at OpenStack Korea ...
 
KubeCon EU 2016: Multi-Tenant Kubernetes
KubeCon EU 2016: Multi-Tenant KubernetesKubeCon EU 2016: Multi-Tenant Kubernetes
KubeCon EU 2016: Multi-Tenant Kubernetes
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
DockerCon EU 2015: The Glue is the Hard Part: Making a Production-Ready PaaS
DockerCon EU 2015: The Glue is the Hard Part: Making a Production-Ready PaaSDockerCon EU 2015: The Glue is the Hard Part: Making a Production-Ready PaaS
DockerCon EU 2015: The Glue is the Hard Part: Making a Production-Ready PaaS
 
KubeCon NA, Seattle, 2016: Performance and Scalability Tuning Kubernetes for...
KubeCon NA, Seattle, 2016:  Performance and Scalability Tuning Kubernetes for...KubeCon NA, Seattle, 2016:  Performance and Scalability Tuning Kubernetes for...
KubeCon NA, Seattle, 2016: Performance and Scalability Tuning Kubernetes for...
 
Load Balancing 101
Load Balancing 101Load Balancing 101
Load Balancing 101
 
NetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksNetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talks
 
Docker Orchestration at Production Scale
Docker Orchestration at Production Scale Docker Orchestration at Production Scale
Docker Orchestration at Production Scale
 
HTTP/2, HTTP/3 and SSL/TLS State of the Art in Our Servers
HTTP/2, HTTP/3 and SSL/TLS State of the Art in Our ServersHTTP/2, HTTP/3 and SSL/TLS State of the Art in Our Servers
HTTP/2, HTTP/3 and SSL/TLS State of the Art in Our Servers
 
Chaos Engineering for Docker
Chaos Engineering for DockerChaos Engineering for Docker
Chaos Engineering for Docker
 
[OpenInfra Days Korea 2018] Day 1 - T4-7: "Ceph 스토리지, PaaS로 서비스 운영하기"
[OpenInfra Days Korea 2018] Day 1 - T4-7: "Ceph 스토리지, PaaS로 서비스 운영하기"[OpenInfra Days Korea 2018] Day 1 - T4-7: "Ceph 스토리지, PaaS로 서비스 운영하기"
[OpenInfra Days Korea 2018] Day 1 - T4-7: "Ceph 스토리지, PaaS로 서비스 운영하기"
 
Spark on Kubernetes - Advanced Spark and Tensorflow Meetup - Jan 19 2017 - An...
Spark on Kubernetes - Advanced Spark and Tensorflow Meetup - Jan 19 2017 - An...Spark on Kubernetes - Advanced Spark and Tensorflow Meetup - Jan 19 2017 - An...
Spark on Kubernetes - Advanced Spark and Tensorflow Meetup - Jan 19 2017 - An...
 
DCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep diveDCUS17 : Docker networking deep dive
DCUS17 : Docker networking deep dive
 
Monitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on Kubernetes
 
Clocker - The Docker Cloud Maker
Clocker - The Docker Cloud MakerClocker - The Docker Cloud Maker
Clocker - The Docker Cloud Maker
 

Similar a Why you’re going to fail running java on docker!

Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant
Ricardo Amaro
 
Drupalcamp es 2013 drupal with lxc docker and vagrant
Drupalcamp es 2013  drupal with lxc docker and vagrant Drupalcamp es 2013  drupal with lxc docker and vagrant
Drupalcamp es 2013 drupal with lxc docker and vagrant
Ricardo Amaro
 
Web scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannelWeb scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannel
purpleocean
 
Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9 Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9
Jérôme Petazzoni
 

Similar a Why you’re going to fail running java on docker! (20)

Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by Docker
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesDocker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
 
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
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Techtalks: taking docker to production
Techtalks: taking docker to productionTechtalks: taking docker to production
Techtalks: taking docker to production
 
JOSA TechTalk: Taking Docker to Production
JOSA TechTalk: Taking Docker to ProductionJOSA TechTalk: Taking Docker to Production
JOSA TechTalk: Taking Docker to Production
 
Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant Automate drupal deployments with linux containers, docker and vagrant
Automate drupal deployments with linux containers, docker and vagrant
 
Security of Linux containers in the cloud
Security of Linux containers in the cloudSecurity of Linux containers in the cloud
Security of Linux containers in the cloud
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
Dockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and NovaDockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and Nova
 
Drupalcamp es 2013 drupal with lxc docker and vagrant
Drupalcamp es 2013  drupal with lxc docker and vagrant Drupalcamp es 2013  drupal with lxc docker and vagrant
Drupalcamp es 2013 drupal with lxc docker and vagrant
 
App container rkt
App container rktApp container rkt
App container rkt
 
Java in containers
Java in containersJava in containers
Java in containers
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
 
Docker San Francisco Meetup April 2015 - The Docker Orchestration Ecosystem o...
Docker San Francisco Meetup April 2015 - The Docker Orchestration Ecosystem o...Docker San Francisco Meetup April 2015 - The Docker Orchestration Ecosystem o...
Docker San Francisco Meetup April 2015 - The Docker Orchestration Ecosystem o...
 
Containers > VMs
Containers > VMsContainers > VMs
Containers > VMs
 
Web scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannelWeb scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannel
 
Docker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQ
Docker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQDocker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQ
Docker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQ
 
Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9 Docker Introduction + what is new in 0.9
Docker Introduction + what is new in 0.9
 
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
 

Más de Red Hat Developers

Más de Red Hat Developers (20)

DevNation Tech Talk: Getting GitOps
DevNation Tech Talk: Getting GitOpsDevNation Tech Talk: Getting GitOps
DevNation Tech Talk: Getting GitOps
 
Exploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on KubernetesExploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on Kubernetes
 
GitHub Makeover | DevNation Tech Talk
GitHub Makeover | DevNation Tech TalkGitHub Makeover | DevNation Tech Talk
GitHub Makeover | DevNation Tech Talk
 
Quinoa: A modern Quarkus UI with no hassles | DevNation tech Talk
Quinoa: A modern Quarkus UI with no hassles | DevNation tech TalkQuinoa: A modern Quarkus UI with no hassles | DevNation tech Talk
Quinoa: A modern Quarkus UI with no hassles | DevNation tech Talk
 
Extra micrometer practices with Quarkus | DevNation Tech Talk
Extra micrometer practices with Quarkus | DevNation Tech TalkExtra micrometer practices with Quarkus | DevNation Tech Talk
Extra micrometer practices with Quarkus | DevNation Tech Talk
 
Event-driven autoscaling through KEDA and Knative Integration | DevNation Tec...
Event-driven autoscaling through KEDA and Knative Integration | DevNation Tec...Event-driven autoscaling through KEDA and Knative Integration | DevNation Tec...
Event-driven autoscaling through KEDA and Knative Integration | DevNation Tec...
 
Integrating Loom in Quarkus | DevNation Tech Talk
Integrating Loom in Quarkus | DevNation Tech TalkIntegrating Loom in Quarkus | DevNation Tech Talk
Integrating Loom in Quarkus | DevNation Tech Talk
 
Quarkus Renarde 🦊♥: an old-school Web framework with today's touch | DevNatio...
Quarkus Renarde 🦊♥: an old-school Web framework with today's touch | DevNatio...Quarkus Renarde 🦊♥: an old-school Web framework with today's touch | DevNatio...
Quarkus Renarde 🦊♥: an old-school Web framework with today's touch | DevNatio...
 
Containers without docker | DevNation Tech Talk
Containers without docker | DevNation Tech TalkContainers without docker | DevNation Tech Talk
Containers without docker | DevNation Tech Talk
 
Distributed deployment of microservices across multiple OpenShift clusters | ...
Distributed deployment of microservices across multiple OpenShift clusters | ...Distributed deployment of microservices across multiple OpenShift clusters | ...
Distributed deployment of microservices across multiple OpenShift clusters | ...
 
DevNation Workshop: Object detection with Red Hat OpenShift Data Science [Mar...
DevNation Workshop: Object detection with Red Hat OpenShift Data Science [Mar...DevNation Workshop: Object detection with Red Hat OpenShift Data Science [Mar...
DevNation Workshop: Object detection with Red Hat OpenShift Data Science [Mar...
 
Dear security, compliance, and auditing: We’re sorry. Love, DevOps | DevNatio...
Dear security, compliance, and auditing: We’re sorry. Love, DevOps | DevNatio...Dear security, compliance, and auditing: We’re sorry. Love, DevOps | DevNatio...
Dear security, compliance, and auditing: We’re sorry. Love, DevOps | DevNatio...
 
11 CLI tools every developer should know | DevNation Tech Talk
11 CLI tools every developer should know | DevNation Tech Talk11 CLI tools every developer should know | DevNation Tech Talk
11 CLI tools every developer should know | DevNation Tech Talk
 
A Microservices approach with Cassandra and Quarkus | DevNation Tech Talk
A Microservices approach with Cassandra and Quarkus | DevNation Tech TalkA Microservices approach with Cassandra and Quarkus | DevNation Tech Talk
A Microservices approach with Cassandra and Quarkus | DevNation Tech Talk
 
GitHub Actions and OpenShift: ​​Supercharging your software development loops...
GitHub Actions and OpenShift: ​​Supercharging your software development loops...GitHub Actions and OpenShift: ​​Supercharging your software development loops...
GitHub Actions and OpenShift: ​​Supercharging your software development loops...
 
To the moon and beyond with Java 17 APIs! | DevNation Tech Talk
To the moon and beyond with Java 17 APIs! | DevNation Tech TalkTo the moon and beyond with Java 17 APIs! | DevNation Tech Talk
To the moon and beyond with Java 17 APIs! | DevNation Tech Talk
 
Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
 
Kafka at the Edge: an IoT scenario with OpenShift Streams for Apache Kafka | ...
Kafka at the Edge: an IoT scenario with OpenShift Streams for Apache Kafka | ...Kafka at the Edge: an IoT scenario with OpenShift Streams for Apache Kafka | ...
Kafka at the Edge: an IoT scenario with OpenShift Streams for Apache Kafka | ...
 
Kubernetes configuration and security policies with KubeLinter | DevNation Te...
Kubernetes configuration and security policies with KubeLinter | DevNation Te...Kubernetes configuration and security policies with KubeLinter | DevNation Te...
Kubernetes configuration and security policies with KubeLinter | DevNation Te...
 
Level-up your gaming telemetry using Kafka Streams | DevNation Tech Talk
Level-up your gaming telemetry using Kafka Streams | DevNation Tech TalkLevel-up your gaming telemetry using Kafka Streams | DevNation Tech Talk
Level-up your gaming telemetry using Kafka Streams | DevNation Tech Talk
 

Último

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 

Why you’re going to fail running java on docker!

  • 1. 1 Why you’re going to FAIL running Java on docker! bit.ly/javadockerfail @burrsutter @rafabene
  • 2. @burrsutter Change History 0.1 - JBCNConf.com 2017 - Barcelona 0.2 - JavaOne 2017 - San Francisco 0.3 - JavaDay UA 2017 - Kiev
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Big Wins for Developers ● Highly Portable Packaging solution - for microservices, web apps ● Lightweight, Encapsulated OS abstraction - carry your OS with you ● Getting Started (docker run -it centos/wildfly) Instantly ● Dev Environments that more closely match Prod Environments ● Dev Environments that match OTHER Dev Environments (no more...but it works on my machine) ● No more waiting 3+ weeks for a VM to be provisioned by Ops just so you can run a series of tests Linux Container
  • 13. Virtualization vs Containers Server Machine Host Operating System Hypervisor Guest OS Guest OS Guest OS Bins Libs Bins Libs Bins Libs App 1 App 2 App 3 Server Machine Host Operating System Bins Libs Bins Libs App 1 App 2 App 3 Docker ● Shared bins/libs and Host Operating System make containers lighter ● You can run multiple versions of app dependencies (Java 6 and 7) ● “Golden Image” deployment model ● Process isolation
  • 14. Pros vs Cons Pros: ● Docker containers start very fast, take less memory ● Super easy to try out a new technology (e.g docker pull centos) ● Supports the “immutable image” deployment model ● It caches layers to make builds faster Cons: ● It is not a VM - it is a process running within the Host OS, do not assume you can run any flavor of container OS on any host OS ● It is not perfectly portable - you will eventually wish to get out of boot2docker-vm into a real Linux VM - one that more closely matches your production environment ● Lineage of docker images at Docker Hub is unknown
  • 15. History of Containers 2000 2010 2005 2015 2000: JAILS ADDED TO FREEBSD 2006: GENERIC PROCESS CONTAINERS 2008: KERNEL AND USER NAMESPACES 2014: GOOGLE KUBERNETES 2008: LINUX CONTAINER PROJECT (LXC) 2015: STANDARDS VIA OCI AND CNCF 2013: RED HAT ENTERPRISE LINUX 2013: DOTCLOUD BECOMES DOCKER 2007: GPC RENAMED CONTROL GROUPS 2003: SELINUX ADDED TO LINUX MAINLINE 2015: RHT CONTAINER PLATFORM 2001: LINUX -VSERVER PROJECT 2013: DOTCLOUD PYCON LIGHTNING TALK 2005: FULL RELEASE OF SOLARIS ZONES
  • 16. History of Java Java 1.0.2 - 30 May 1996 J2EE 1.2 - 12 Dec 1999 https://en.wikipedia.org/wiki/Java_EE_version_history#J2EE_1.2_.28December_12.2C_1999.29 https://en.wikipedia.org/wiki/Java_version_history
  • 17.
  • 18. A Challenge Server Hardware Operating System Application Server .war or .ear Java Virtual Machine Custom Configuration Linux Kernel Version & Distribution Java 1.6.6_45 or Java 1.7.0_67 Weblogic 10.x.y, Tomcat 6.x.y, JBoss EAP 6.x.y JDBC driver, datasource, JMS queue, users Have you ever had “/” vs “” break your app? Or perhaps needed a unique version of a JDBC driver? Or had a datasource with a slightly misspelled JNDI name? Or received a patch for the JVM or app server that broke your code? Containerize Your App
  • 19. Email MyApp.war has been tested with the following On my Windows 7 desktop JDK 1.8.43 Wildfly 9 Configuration: Datasource: MySQLDS Tested with: mysql-connector-java-5.1.31-bin.jar Production Environment Red Hat Enterprise Linux 6.2 JRE 1.7.3 WebSphere 8.5.5 Oracle 9
  • 20. Dockerfile Container Guest OS Java App Server custom configuration FROM centos/wildfly COPY standalone.xml /opt/wildfly/standalone/configuration/ COPY mysql-connector-java-5.1.31-bin.jar /opt/wildfly/standalone/deployments/ COPY mysql-sample-ds.xml /opt/wildfly/standalone/deployments/ COPY myapp/target/your.war /opt/wildfly/standalone/deployments/ your.war dependencies Note: There are better ways to handle Java apps, this is for illustration purposes
  • 21.
  • 23. Cgroups and Namespaces Cgroups - cpu (cpu shares) - cpuacct - cpuset (limit processes to a CPU) - memory (swap, dirty pages) - blkio (throttle reads/writes) - devices - net_prio (packet class and priority) - freezer Namespaces - pid (processes) - net (network interfaces, routing) - ipc (system V ipc) - mnt (mount points, filesystems) - uts (hostname) - user (UIDs)
  • 24. /sys/fs/cgroup/memory cgroup.clone_children memory.kmem.tcp.limit_in_bytes memory.move_charge_at_immigrate cgroup.event_control memory.kmem.tcp.max_usage_in_bytes memory.oom_control cgroup.procs memory.kmem.tcp.usage_in_bytes memory.pressure_level memory.failcnt memory.kmem.usage_in_bytes memory.soft_limit_in_bytes memory.force_empty memory.limit_in_bytes memory.stat memory.kmem.failcnt memory.max_usage_in_bytes memory.swappiness memory.kmem.limit_in_bytes memory.memsw.failcnt memory.usage_in_bytes memory.kmem.max_usage_in_bytes memory.memsw.limit_in_bytes memory.use_hierarchy memory.kmem.slabinfo memory.memsw.max_usage_in_bytes notify_on_release memory.kmem.tcp.failcnt memory.memsw.usage_in_bytes tasks
  • 26. DevOps Challenges for Multiple Containers ▪ How to scale? ▪ How to avoid port conflicts? ▪ How to manage them on multiple hosts? ▪ What happens if a host has trouble? ▪ How to keep them running? ▪ How to update them? ▪ Where are my containers? Node Node Node Node Node Logger Node
  • 28.
  • 29. ▪ Greek for “Helmsman,” also the root of the word “Governor” (from latin: gubernator) ▪ Container orchestrator ▪ Supports multiple cloud and bare-metal environments ▪ Inspired by Google’s experience with containers ▪ Open source, written in Go ▪ Manage applications, not machines Meet Kubernetes
  • 30. SCM (Git/Svn) Master API Server Service Layer VirtualPhysical Private Public Persistent Storage Node Node Logger Node Node Node Node Dev Ops CI/CD Automation Routing Layer Registry SDN Overlay Network Controllers - Scheduler - Deployments - Services - Builds - Routes - DeploymentConfigs Kubernetes OpenShift - Builds - ImageStreams
  • 31. SCM (Git/Svn) Master API Server Service Layer VirtualPhysical Private Public Persistent Storage Node Node Logger Node Node Node Node Dev Ops CI/CD Automation Routing Layer Registry SDN Overlay Network Controllers - Scheduler - Deployments - Services - Builds - Routes - DeploymentConfigs Kubernetes OpenShift - Builds - ImageStreams
  • 32. SCM (Git/Svn) Master API Server Service Layer VirtualPhysical Private Public Persistent Storage Node Node Logger Node Node Node Node Dev Ops CI/CD Automation Routing Layer Registry SDN Overlay Network Controllers - Scheduler - Deployments - Services - Builds - Routes - DeploymentConfigs Kubernetes OpenShift - Builds - ImageStreams
  • 34. Why Fail? 8GB 4 cores 64GB 16 cores Developer Workstation Production Server
  • 35. @burrsutter System.out.println("Memory: " + Runtime.getRuntime().maxMemory()/1024/1024); System.out.println("CPUs: " + Runtime.getRuntime().availableProcessors()); Why does Java Fail? It sees ALL the HOST resources, it is blind to cgroups by default Note: free also fails https://fabiokung.com/2014/03/13/memory-inside-linux-containers/
  • 38. @burrsutter Memory (max heap defaults to ¼ of available memory) JIT Optimizations Mode: Client or Server Thread Management Garbage Collector Do NOT just “java -jar myVertxApp.jar” nor “java -jar mySpringBootApp.jar” Do try “java -XX:+PrintFlagsFinal -XX:+PrintGCDetails $JAVA_OPTIONS -jar myApp.jar” JVM Ergonomics https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/ergonomics.html
  • 40. @burrsutter Heap (-Xms -Xmx) ------------------------------ Native JRE Perm (-XX:MaxPermSize), Java8 Meta (-XX:SurvivorRatio, -XX:MaxNewSize, -XX:NewRatio) JIT Bytecode JNI NIO Threads (defaults to 512K to 1024K depending on platform) Tip: Either -Xmx at 50% of container constrained memory or -XX:MaxRam=500m - your heap will be approximately 250mb * JVM Memory: Heap is about 50%
  • 42. @burrsutter https://hub.docker.com/r/fabric8/java-jboss-openjdk8-jdk/ https://github.com/fabric8io-images/java/blob/master/images/jboss/openjdk8/jdk/container-limits max_memory() { # High number which is the max limit until which memory is supposed to be # unbounded. local max_mem_unbounded="$(cat /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes)" local mem_file="/sys/fs/cgroup/memory/memory.limit_in_bytes" if [ -r "${mem_file}" ]; then local max_mem="$(cat ${mem_file})" if [ ${max_mem} -lt ${max_mem_unbounded} ]; then echo "${max_mem}" fi fi } Workaround docker pull fabric8/java-jboss-openjdk8-jdk
  • 43. @burrsutter Heap Patched: Java 8u131, included in Java 9 https://bugs.openjdk.java.net/browse/JDK-8170888
  • 44. @burrsutter Try it yourself Just need Docker for Mac or Windows docker run -m 100MB openjdk:8u121 java -XshowSettings:vm -version vs docker run -m 100MB openjdk:8u131 java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XshowSettings:vm -version UseCGroupMemoryLimitForHeap tells the JVM to look to the cgroup’s value for memory in /sys/fs/cgroup/memory/memory.limit_in_bytes
  • 46. @burrsutter docker run --cpus="1.5" -m 400M openjdk:8u131 *docker run --cpu-quota=150000 --cpu-period=100000 -m 400M openjdk:8u131 docker run --cpu-shares=1536 -m 400M openjdk:8u131 **docker run --cpuset-cpus=0,2 -m 400M openjdk:8u131 Docker CPU Settings https://docs.docker.com/engine/admin/resource_constra ints/#configure-the-default-cfs-scheduler * Kubernetes uses this model ** JVM properly calculates availableProcessors()
  • 47. @burrsutter docker run -it --cpus="2" -m 200M java java -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2 -Djava.util.concurrent.ForkJoinPool.common.parallelism=2 -XX:MaxRam=200m // Half a core cpu-quota / cpu-period docker run -it --cpu-quota=50000 --cpu-period=100000 -m 200M openjdk:8u131 java -XX:+UseSerialGC -Xmx=100m Note: Set Max heap (-Xmx) to about 50% of total container memory Note: UseSerialGC when core count is below 2 Docker CPU Mapped to Java Some “rules of thumb”
  • 50. @burrsutter Base Docker Image FROM fabric8/java-jboss-openjdk8-jdk:1.2.7 Maven Plugin: - Docker builds leveraging base image - Deploys to Kubernetes and OpenShift easily https://fabric8.io/gitbook/mavenPlugin.html mvn io.fabric8:fabric8-maven-plugin:3.3.5:setup mvn fabric8:deploy Hot Tips https://hub.docker.com/r/fabric8/java-jboss-openjdk8-jdk/
  • 51. @burrsutter More and More Resources https://developers.redhat.com/products/cdk/download/ https://github.com/burrsutter/javadockerfail https://developers.redhat.com/blog/2017/03/14/java-inside-docker/ https://developers.redhat.com/blog/2017/04/04/openjdk-and-containers/ https://dzone.com/articles/running-a-jvm-in-a-container-without-getting-kille https://github.com/redhat-developer-demos/java-container https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how- pods-with-resource-limits-are-run https://github.com/fabric8io-images/java/tree/master/images/jboss/openjdk8/jdk https://github.com/fabric8io-images/java/blob/master/images/jboss/openjdk8/jdk/container-limits http://cs.oswego.edu/pipermail/concurrency-interest/2016-March/015014.html bit.ly/javadockerfail
  • 52. 52 Why you’re going to FAIL running Java on docker! bit.ly/javadockerfail @burrsutter @rafabene
  • 54.
  • 55. Creative Commons/Flikr, SF History Center, SF Public Library, GG Bridge 1935-1936 at http://www.onlyinyourstate.com/northern-california/san-francisco/life-san-francisco-1935/
  • 56. Creative Commons/Flikr, SF History Center, SF Public Library, GG & Bay Bridges 1935 at http://www.onlyinyourstate.com/northern-california/san-francisco/life-san-francisco-1935/
  • 57. Creative Commons Found SF Historical Archive, GG & Bay Bridges, at http://www.onlyinyourstate.com/northern-california/san-francisco/life-san-francisco-1935/
  • 58.
  • 59. Creative Commons Photo ‘For Bankrupt Hanjin, Costs and Containers Pile Up’ at https://www.workboat.com/news/bluewater/hanjin-costs-containers-pile-up-us-ports/
  • 60. Wikimedia Commons ‘Container Port & Toxic Fire San Francisco’ at https://commons.wikimedia.org/wiki/File:Containter_port_and_toxic_fire,_San_Francisco.jpg