Akka can be used in different ways:
- As a library: used as a regular JAR on the classpath and/or in a web app, to be put into
- As an application packaged with sbt-native-packager
sbt-native-packager is a tool for creating distributions of any type of application, including Akka applications.
Define sbt version in
Add sbt-native-packager in
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.5")
Follow the instructions for the
JavaAppPackaging in the sbt-native-packager plugin documentation.
You can use both Akka remoting and Akka Cluster inside of Docker containers. But note that you will need to take special care with the network configuration when using Docker, described here: Akka behind NAT or in a Docker container
For the JVM to run well in a Docker container, there are some general (not Akka specific) parameters that might need tuning:
Docker allows constraining each containers’ resource usage.
You may want to look into using
-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap options for your JVM later than 8u131, which makes it understand c-group memory limits. On JVM 10 and later, the
-XX:+UnlockExperimentalVMOptions option is no longer needed.
For multi-threaded applications such as the JVM, the CFS scheduler limits are an ill fit, because they will restrict the allowed CPU usage even when more CPU cycles are available from the host system. This means your application may be starved of CPU time, but your system appears idle.
For this reason, it is best to avoid
--cpu-quota entirely, and instead specify relative container weights using
To take advantage of the fact that your are running inside of Kubernetes while forming a cluster, you can use the Akka Cluster Bootstrap module.
You can look at the Cluster with Kubernetes example project to see what this looks like in practice.
To avoid CFS scheduler limits, it is best not to use
resources.limits.cpu limits, but use
resources.requests.cpu configuration instead.