Fly.ioExplainer
Corrosion
Summary
Corrosion is Fly.io’s open-source service discovery and state synchronization system, built to distribute routing data across globally deployed edge proxies and worker servers. It replaces centralized consensus-oriented designs with a Rust program that propagates a SQLite database through SWIM-based gossip and QUIC, using cr-sqlite’s CRDT tables and logical timestamps to reconcile updates without locking, a central server, or distributed consensus. The system’s design follows link-state routing ideas and exploits Fly.io’s fully connected WireGuard mesh, while worker-owned state keeps conflicts uncommon. The post also documents failures, including a contagious Rust RWLock deadlock, a nullable-column migration that triggered large-scale reconciliation, and the need for backups, whole-dataset republishing, testing, and regionalization to reduce blast radius. Corrosion now converges in seconds across thousands of workers.
Context
Fly.io needed a globally synchronized routing map because its orchestration model makes individual worker servers authoritative for their workloads. Existing approaches based on Consul, SQLite caches, and distributed consensus imposed costs or risks that did not fit a globally distributed platform.
Approach / What changed
Corrosion is a Rust service that propagates SQLite databases over a fully connected WireGuard mesh. It uses SWIM for membership, QUIC for broadcasting and reconciliation, and cr-sqlite CRDT tables with logical timestamps to converge state without locking, central servers, or distributed consensus. Later changes added checkpoint backups, whole-dataset republishing, extensive testing, and regionalization.
Takeaways
Corrosion combines SWIM membership gossip with QUIC update distribution and cr-sqlite CRDT tables, which apply changes using last-write-wins logical timestamps.
Worker-owned state avoids bottlenecking on a globally consistent central scheduler because updates from different workers almost never conflict.
Regionalization separates fine-grained regional clusters from a global application-to-region map, reducing the blast radius of state-related bugs; checkpoint backups support rebuilding the database.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.