Erlang and Akka Actors - A story of tradeoffs
The Actor model has long been known to be great at modeling concurrent and parallel problems in a declarative, safe way. The challenge has always been the cost of this abstraction - implementing cheap message passing over a shared-nothing memory architecture while ensuring fairness is a tough ask. In this talk I shall go over how BEAM, with it's three decades of esoteric telecom engineering differs from Akka actors implemented over the JVM, arguably the most invested general purpose VM in existence today.
Along the way, we shall discover how design decisions affect performance at each step of a program's execution - from a global/per-process heap affecting GC latencies and throughput, a type system's effects at efficiency, to preemptive scheduling improving long tail latencies.
Outline/Structure of the Talk
This talk shall be divided into 4 phases.
- Quick summary of Actor model (10 minutes)
- Immutability, Message Passing and Behavior
- Other similar approaches (CSP)
- Erlang Actors in depth
- What's the true cost of message passing? (5m)
- Immutability tradeoffs
- Latencies: Pre-emptive scheduling and Per-process GC (5m)
- Benchmark and measure p95 latency of a concurrent app.
- Supervision trees, Type-safety and Let-it-Crash (5m)
- Benefits of being stateless and declarative
- What's the true cost of message passing? (5m)
- Akka Actors in depth
- JVM shared-memory model - Perf benefits and consequences (4m)
- Global GC - unpredictable long tail latencies (4m)
- JVM advantages - JIT, Type System, Mixed Schedulers (5m)
- Akka Typed
- Conclusion/Questions (7 minutes)
Learning Outcome
This will be a deep-dive, and an attendee can expect to:
- Gain solid intuition into what makes BEAM truly unique at concurrency
- Tradeoffs of implementing the Actor model on a general purpose VM
- Have insights into what metrics/paradigms to consider when evaluating concurrency capabilities of a language.
Target Audience
Intermediate programmers who have worked with concurrent codebases and preferably dabbled with at least one functional language
Video
Links
At Housing.com, we were one of the earliest proponents of the Elixir/Erlang ecosystem and we wrote a bunch of our core services in the language. I've co-presented a talk at The Fifth Elephant 2015 detailing our experiences - Fifth Elephant Talk.
At my current role at Amazon, I write big data applications in Scala on Apache Spark.