Wiki: Handling millions of connections in Cowboy using Elixir
For agents: Markdown version · Wiki index · Explore
- Speaker: Joey Feldberg
- Event: Reversim Summit 2016
- Video: https://www.youtube.com/watch?v=Tck4DQkL-Us
- Transcript: /transcripts/2016/18-Tck4DQkL-Us.md
- Language: Hebrew · Type: talk · Level: intermediate
- Topics: Distributed Systems, Scalability, Architecture, Software Engineering
Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.
Summary
The speaker discusses how to build a high-concurrency real-time messaging system using Erlang and Elixir, aiming to handle millions of concurrent connections on limited hardware. The presentation contrasts traditional languages like Java and Ruby with the actor-model approach of the Erlang Virtual Machine to achieve fault tolerance and scalability. Through a live coding demonstration, the speaker shows how Elixir simplifies Erlang’s syntax while retaining its native clustering and process supervision capabilities. The audience learns how lightweight processes and supervision trees enable building robust, distributed backend architectures with minimal code.
Key points
- 2:18 The project requirement was to build a real-time in-app messaging system capable of supporting millions of concurrent client connections and low latency.
- 5:26 Evaluating Java-based open-source websocket servers showed they struggled to scale efficiently to one million connections per server without exhausting CPU and memory.
- 7:31 Erlang and Elixir provide native concurrency and fault tolerance, famously utilized by large messaging platforms like WhatsApp.
- 9:33 While Erlang is extremely powerful for real-time systems, its Prolog-derived syntax can feel dated and cumbersome to developers.
- 10:44 Elixir acts as a modern wrapper over the Erlang Virtual Machine, combining Erlang’s battle-tested runtime with a syntax heavily inspired by Ruby.
- 16:00 The execution model relies on lightweight processes instead of operating system threads or heavy objects, allowing millions of isolated processes to run concurrently.
- 17:06 Supervisor trees automatically monitor worker processes and restart them upon failure, ensuring fault tolerance out of the box.
- 31:55 A single server running Elixir successfully handled hundreds of thousands of concurrent websocket connections and messages with minimal resource consumption.
Takeaways
- Use lightweight actor-model processes instead of traditional thread-per-connection models for high-concurrency real-time servers.
- Leverage built-in supervision trees to design self-healing backend systems that automatically recover from failures.
- Adopt Elixir when you want modern language ergonomics and syntax combined with the battle-tested scalability of the Erlang Virtual Machine.
Questions this talk answers
- How does the Erlang Virtual Machine handle millions of concurrent connections without exhausting system memory or CPU?
- What are the main architectural differences between using actor-based languages like Elixir versus traditional thread-per-request servers in Java?
- How do supervision trees and process isolation prevent a failure in a single client connection from crashing the entire server?
Technologies
Elixir, Erlang, Ruby, Java, Node.js, Linux
Tags
backend architecture, concurrency, distributed systems, fault tolerance, scalability, websockets