- GigaElixir Gazette
- Posts
- đź§ Your Concurrency Model Feels Like Magic Until You Build It
đź§ Your Concurrency Model Feels Like Magic Until You Build It
BEAM's processes aren't magic—reduction budgets create the illusion of preemption on cooperative scheduling
Welcome to GigaElixir Gazette, your 5-minute digest of Elixir ecosystem news that actually matters đź‘‹.
. WEEKLY PICKS .
🚀 Phoenix LiveView Packages as Cross-Platform Desktop App: Single-binary applications for Linux, macOS, Windows using Burrito and Tauri's sidecar architecture. Backend bundles with embedded ERTS, Tauri webview connects to localhost:4000. No external dependencies required. Tutorial covers Dockerfile configs and cargo-xwin cross-compilation from Linux.
🗺️ Leaflet Maps in LiveView with Colocated Hooks: Two-step integration for interactive map-based reporting. Import Leaflet via CDN, initialize using Phoenix colocated hooks directly in LiveView. Distribution system uses red-highlighted areas to spot stockouts faster than tables. Pattern works for any JavaScript library.
📦 Custom Ecto Types Eliminate Virtual Field Loading: Encapsulate cast/load/dump logic in single module. Category structs load automatically from database IDs without manual helpers. Queries stay natural—Ecto translates structs to integers via dump/1. Prevents "forgot to load" bugs plaguing virtual field patterns.
💰 Full Phoenix Stack on $5 VPS with Dokploy: Self-hosted Docker deployments with web UI. Developers moving from Fly.io to Hetzner VPS—fraction of cost. Two-click deployment vs AWS complexity. Hostinger VPS + Dokploy runs frontend, backend, database for 6.50AU6.50 AU 6.50AU/month. Declarative configs treat servers like cattle.
🤔 Rails vs Phoenix Architecture Debate for Solo Devs: Framework choice for MVPs explored. Phoenix LiveView eliminates separate frontend stack. Elixir's fault tolerance vs Rails' mature ecosystem. Community suggests starting with familiar stack, migrating when concurrency becomes bottleneck.

Your Concurrency Model Feels Like Magic Until You Build It
I was fascinated with BEAM—how it spawned processes without shared state, sent messages, built supervision trees. I wanted to see what it takes to support them. So I built my own toy BEAM.
Spawning processes? Trivial. Dictionary of PIDs to programs, ready queue, increment counter. Just data structures.
Then I hit the problem. My scheduler was cooperative. A process with Work 999 blocked everything. Started processes won't stop mid-execution.
BEAM's solution: reduction budgets. Every process gets 4,000 reductions. After each function call, decrement. Hit zero? Pause, start another process. This creates preemptive illusion on cooperative foundations.
Process has 7 reductions, wants 999 work? Do 7, store 992 remaining, pause. Next process runs. Later, do another 7. Repeat.
Why this works: recursion everywhere. Iterating lists? Recursive calls. Processing messages? Function calls. Each call is a yield point. Functional programming naturally creates thousands of yield points.
Mailboxes are queues. Send enqueues to destination. Receive scans until finding wanted message, removes it, continues. Not found? Sleep. Send wakes it up.
Links completed it. Bidirectional connections. One crashes? Send system message to linked processes. They decide: respawn? Crash ourselves? Supervision trees arise from this.
BEAM's reputation comes from primitives that compose beautifully. Cooperative scheduling + reduction budgets = preemptive illusion. Mailbox queues + selective receive = async messaging. Links + crash messages = supervision trees.
Go goroutines share memory—one corrupts data, everyone suffers. Erlang processes share nothing—one crashes, supervisor restarts in milliseconds. When primitives isolate failures by default, systems stay calm.
Remember, for understanding BEAM:
Reduction budgets create preemption – Yield points after every function call create preemptive illusion on cooperative scheduling
Recursion naturally yields – Functional patterns provide thousands of yield points without explicit coordination
Primitives compose simply – Power comes from interaction, not individual complexity
Isolation makes calm systems – Share-nothing means failures stay contained, restart instantly
. TIRED OF DEVOPS HEADACHES? .
Deploy your next Elixir app hassle-free with Gigalixir and focus more on coding, less on ops.
We're specifically designed to support all the features that make Elixir special, so you can keep building amazing things without becoming a DevOps expert.
See you next week,
Michael
P.S. Forward this to a friend who loves Elixir as much as you do đź’ś