Docker and OTP: Friends or Foes? (ElixirConf 2018)
Tags: elixir, docker, kubernetes, otp
Published: 2019-07-08 20:38:37

---
title: Docker and OTP: Friends or Foes? (ElixirConf 2018)
published: true
tags: elixir, docker, kubernetes, otp
canonical_url: https://daniel-azuma.com/articles/talks/elixirconf-2018
---

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.

## Talk resources

- [Video on YouTube](https://www.youtube.com/watch?v=nLApFANtkHs)
- [Slides on SpeakerDeck](https://speakerdeck.com/dazuma/docker-and-otp-friends-or-foes)

## Code and libraries used in the talk

- The Elixir Tank game is on Github at [https://github.com/ElixirSeattle/tanx](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](https://github.com/bitwalker/libcluster).
- The Horde library that provides “distributed” supervisor and registry implementations is on Github at [https://github.com/derekkraan/horde](https://github.com/derekkraan/horde).
- The CRDT library underlying the handoff process is on Github at [https://github.com/derekkraan/delta\_crdt\_ex](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](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](https://lasp-lang.org).

## Links and articles

- [Gigalixir](https://gigalixir.com) 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](https://medium.com/@derek.kraan2/introducing-horde-a-distributed-supervisor-in-elixir-4be3259cc142) and [Getting Started with Horde](https://medium.com/@derek.kraan2/getting-started-with-hordes-distributed-supervisor-registry-f3017208e1ce).
- Ellis Pritchard discusses the Kubernetes/OTP shutdown process in some depth in his article [Graceful shutdown on Kubernetes with signals and Erlang OTP 20](https://medium.com/@ellispritchard/graceful-shutdown-on-kubernetes-with-signals-erlang-otp-20-a22325e8ae98).
- Chirag Singh Toor wrote up his experience [writing a similar system](https://engineering.dollarshaveclub.com/elixir-otp-applications-on-kubernetes-9944636b8609), 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

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.