By Terry Goss, CC BY 2.5, https://commons.wikimedia.org/w/index.php?curid=1561215

Things that go wrong when deploying Java with containers

Martin Lehmann

@theneva

FINN.no

(and how to avoid them)

Get to know your app!

  • ~1000 req/s @ peak traffic
     
  • 6M unique visitors / week
  • App config confined to app repo
     
  • Easier to start apps locally and in CI
     
  • Higher dev/production parity
     
  • Automatic horisontal scaling
     
  • Overall improved performance at much lower cost

A tale of CPU and memory

OOMKilled!

  • Memory request = 1G
     
  • Memory limit = 1,3G
     
  • Max heap size = 0,6 * Limit = 0,78

Hystrix <3 72 CPUs

Java >= 8u131

(April 2017)

 

  • -XX:+UnlockExperimentalVMOptions
  • -XX:+UseCGroupMemoryLimitForHeap

By Chagai at English Wikipedia - Transferred from en.wikipedia to Commons., Public Domain, https://commons.wikimedia.org/w/index.php?curid=3839230

Your message was sent in 2 hours.

By maix - Based on blank map of Europe.svg, source: Time zones of Europe.png;, CC SA 1.0, https://commons.wikimedia.org/w/index.php?curid=1641488

  • UTC is great!
     
  • Except when locales aren't configured

What can we do?

Know your app before you run it!

  • (How) do you need to tune the JVM?
     
  • Do you have anything that scales by CPUs?
     
  • Which resources does your app really need?
     
  • Make it easy to do the right thing!

Help your developers!

FROM <container registry>/finntech/java8:8

ENV LC_ALL "no_NB.UTF-8"
ENV LANG "no_NB.UTF-8"
ENV TZ "Europe/Oslo"

ENV JAVA_OPTS -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector

COPY build/libs/ad-input-server-*.war /app

So: avoid great white sharks by…

  • Knowing your app's requirements and dependencies!
     
  • Making it easy to do the right thing
     
  • Expecting failure, and enabling easy rollback

Martin Lehmann

@theneva
 

FINN.no / @FINN_tech / tech.finn.no

https://www.finn.no/apply-here

Come talk to us!

Things that go wrong when deploying Java with containers (and how to avoid them)

By theneva

Things that go wrong when deploying Java with containers (and how to avoid them)

60-ish minute talk for JavaZone Oslo 2017

  • 641