LaVOZs

The World’s Largest Online Community for Developers

'; scala - What are the downsides to containerizing akka apps - LavOzs.Com

What are the downsides, gotchas, or things that one needs to be aware of when containerizing Akka apps. Are there things to be avoided? Libraries that help? What is the best process for containerizing an akka app or best practices. Any links to articles would be appreciated.

This question is really too broad for stack exchange, but I'll give a couple of quick suggestions since it doesn't look like it's going to get flagged as too broad.

SBT Native Packager is the typical way to package akka applications for Docker. Although I understand there are similar tools for other build chains.

As far as "best practices", I don't think there's anything particularly different than any other JVM Docker images. e.g.:

  • One process per container. So, no, you don't put a cluster per container: you put one node per container: that way you can scale up and scale down just by adding/removing containers. (And do rolling upgrades, etc.)
  • Don't use CPU limits
  • Be aware that the JVM (especially Java8) may report all of the CPUs & memory on the host, so you may want to manually set your thread and memory settings or look into the JVM flags that can alleviate this such as -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
  • Minimum privilege etc. SBT Native Packager has reasonable defaults for this this, but normal advice about using a suitable base image and other general Dockerfile advice applies.

There are also, of course, the actual Akka docs deploying to Docker as well.

One thing that you may find helpful is the Lightbend article on running Lagom on Kubernetes. Since it's Lagom (rather than just Akka) and Kubernetes (rather than just containers) it will be a superset of things you care about. (For example, you won't care about the Postgres/Kafka setup.) But it also just contains lots of good advice in general about running in containers:

  • Heap sizes
  • How to manage configurations
  • Using git hashes for versions to make docker tagging more sane
  • How to use native packager
  • How to use Akka bootstrap (although you will have to modify this a bit if you aren't using Kubernetes
Related
Blocking IO in Akka
Get environment variable value in Dockerfile
What is the difference between CMD and ENTRYPOINT in a Dockerfile?
What is the difference between the 'COPY' and 'ADD' commands in a Dockerfile?
Unable to access Scala's Akka libraries in JRuby
Docker Compose vs. Dockerfile - which is better?
scala and akka on linux: compiling and executing