On Sept 7, 2018, I spoke on "Docker and OTP: Friends or Foes?" at ElixirConf in Bellevue, WA. The talk discussed ideas for making OTP applications work together with container-based deployments.
As a community, we sometimes believe that OTP and containers/cloud are incompatible, and we too often conclude that we must choose one over the other. I argued that we should instead look for creative ways to combine the strengths of the two platforms. As an example, I demonstrated an online real-time game, written using Elixir/Phoenix, that uses process migration to survive container-based updates.
Code and libraries used in the talk
The Elixir Tank game is on Github at https://github.com/ElixirSeattle/tanx.
The LibCluster library used to build an Erlang cluster from the Kubernetes API is on Github at https://github.com/bitwalker/libcluster.
The Horde library that provides “distributed” supervisor and registry implementations is on Github at https://github.com/derekkraan/horde.
The CRDT library underlying the handoff process is on Github at https://github.com/derekkraan/delta_crdt_ex.
Other libraries of interest
An alternate library that could be used for process migration is Swarm, which can be found on Github at https://github.com/bitwalker/swarm.
Lasp is a collection of libraries for building large distributed systems in Erlang/Elixir. It includes a replacement for distributed Erlang, as well as implementations for global registries, CRDTs, and more. Information is available at https://lasp-lang.org.
Links and articles
- Gigalixir is a hosting service that is optimized for Elixir applications, and is able to perform OTP hot upgrades in containers.
- Derek Kraan wrote a couple of articles useful for getting started with Horde: Introducing Horde and Getting Started with Horde.
- Ellis Pritchard discusses the Kubernetes/OTP shutdown process in some depth in his article Graceful shutdown on Kubernetes with signals and Erlang OTP 20.
- Chirag Singh Toor wrote up his experience writing a similar system, including detailed code. A very useful read!
I also intend to write a few posts myself covering some of this material in a bit more detail, so watch this space in the future.
Thanks to Ben, Kyle, and Greg for joining me in writing the original Tanx app… has it really been three years?? Thanks to Google for sponsoring my appearance at ElixirConf this year, and to the Elixir team at Google for helpful feedback on my talk and demo.