# Erlang/OTP — Battle-Tested Platform for Massively Concurrent Systems > Erlang/OTP is a programming language and runtime platform designed for building fault-tolerant, distributed, real-time systems with soft real-time guarantees and hot code upgrades. ## Install Save as a script file and run: # Erlang/OTP — Battle-Tested Platform for Massively Concurrent Systems ## Quick Use ```bash # Install on Ubuntu/Debian sudo apt install erlang # Start interactive shell erl # Compile and run a module erlc hello.erl && erl -noshell -s hello start -s init stop ``` ## Introduction Erlang was created at Ericsson in the 1980s to build telecom switches that could never go down. Together with OTP (Open Telecom Platform), it provides a runtime, libraries, and design principles for building systems that handle millions of concurrent connections with uptimes measured in nines. ## What Erlang/OTP Does - Runs millions of lightweight processes on a single machine with preemptive scheduling - Provides fault tolerance through supervisor trees that restart failed processes automatically - Supports hot code swapping so running systems can be upgraded without downtime - Enables transparent distribution where processes communicate across nodes seamlessly - Includes OTP behaviors (gen_server, gen_statem, supervisor) that codify proven concurrency patterns ## Architecture Overview The BEAM virtual machine runs Erlang and other languages (Elixir, Gleam) with per-process heaps and a preemptive scheduler. Each Erlang process is extremely lightweight (about 300 bytes) and communicates solely through asynchronous message passing. The scheduler distributes processes across CPU cores with reduction counting for fair time-slicing. OTP's supervisor trees organize processes into hierarchical restart strategies (one-for-one, one-for-all, rest-for-one), enabling self-healing systems where crashes are isolated and recovered automatically. ## Self-Hosting & Configuration - Install from official packages on Linux, macOS (Homebrew), or Windows (Chocolatey) - Use `rebar3` as the build tool and dependency manager for Erlang projects - Configure application settings in `sys.config` and VM arguments in `vm.args` - Create releases with `rebar3 release` for self-contained deployable packages - Tune the BEAM VM with flags like `+P` (max processes), `+S` (schedulers), and `+K true` (kernel poll) ## Key Features - Soft real-time garbage collection per process eliminates global GC pauses - Pattern matching on messages and data structures as a core language feature - Built-in distributed computing with Erlang distribution protocol for clustering nodes - Hot code upgrade support that swaps modules while the system keeps running - Battle-tested reliability powering WhatsApp, RabbitMQ, CouchDB, and global telecom infrastructure ## Comparison with Similar Tools - **Elixir** — modern syntax running on the same BEAM VM; Erlang is lower-level with direct access to OTP internals - **Go** — goroutines provide concurrency but lack Erlang's fault tolerance primitives and hot code reloading - **Rust** — memory safety and performance but no built-in actor model or supervisor trees for self-healing - **Akka (Scala/Java)** — actor model inspired by Erlang but runs on the JVM without per-process GC or native hot upgrades - **Node.js** — single-threaded event loop; Erlang runs true parallel processes with preemptive scheduling across all cores ## FAQ **Q: Is Erlang still relevant when Elixir exists?** A: Yes. Elixir runs on the BEAM and depends on Erlang/OTP underneath. Many core libraries (mnesia, ssl, crypto) are Erlang modules, and understanding Erlang is valuable for debugging and optimizing BEAM applications. **Q: How does Erlang handle millions of concurrent connections?** A: Each connection maps to a lightweight BEAM process. The scheduler handles millions of these processes with microsecond context switches and per-process garbage collection. **Q: What is the learning curve for Erlang?** A: Erlang's syntax (based on Prolog) and functional, immutable approach can feel unfamiliar. The concepts of OTP behaviors and supervision trees require study but pay off in reliability. **Q: Who uses Erlang in production today?** A: WhatsApp handles billions of messages on Erlang. Discord, RabbitMQ, Riak, CouchDB, and most telecom infrastructure rely on Erlang/OTP for their concurrency and uptime requirements. ## Sources - https://github.com/erlang/otp - https://www.erlang.org/ --- Source: https://tokrepo.com/en/workflows/a916cb11-40c3-11f1-9bc6-00163e2b0d79 Author: Script Depot