---
title: "Corrosion"
description: "Corrosion is Fly.io's open-source service discovery system: a Rust program that propagates a SQLite database across thousands of workers via SWIM gossip and QUIC, using the cr-sqlite CRDT extension with last-write-wins logical timestamps instead of distributed consensus."
url: "https://swe.quest/articles/corrosion-041c41646926d669"
canonical: "https://fly.io/blog/corrosion/"
source: "Fly.io"
published: "2025-10-22"
difficulty: "medium"
kind: "Case study"
reading_minutes: 9
tags: ["distributed-systems","replication","sqlite","incident-response","rust"]
---

# Corrosion

A post on [Fly.io](https://swe.quest/sources/flyio.md), published 2025-10-22, 9 min read, Case study. Original: [https://fly.io/blog/corrosion/](https://fly.io/blog/corrosion/)

## Summary

Corrosion is Fly.io's open-source service discovery system: a Rust program that propagates a SQLite database across thousands of workers via SWIM gossip and QUIC, using the cr-sqlite CRDT extension with last-write-wins logical timestamps instead of distributed consensus. It works because Fly's orchestration makes individual workers the source of truth for their own state, so updates rarely conflict, much like a link-state routing protocol such as OSPF. The war stories cover a Rust RwLock deadlock gossiped to every proxy that caused a fleet-wide outage, a nullable-column migration that triggered a cr-sqlite backfill storm, and Consul certificate expiry that drove Corrosion writes until uplinks saturated. The fixes are Tokio event-loop watchdogs, Antithesis testing, checkpoint backups for cluster rebuilds, republishing full Machine state instead of partial updates, and regionalized two-level clusters to shrink the blast radius.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Distributed systems](https://swe.quest/tags/distributed-systems.md) (Distributed systems)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [Incidents & postmortems](https://swe.quest/tags/incident-response.md) (Reliability & operations)
- [Rust](https://swe.quest/tags/rust.md) (Languages)

## Prerequisites

- gossip protocols
- CRDTs ([easy posts on Consistency models](https://swe.quest/tags/consistency.md?difficulty=easy))
- SQLite ([easy posts on SQLite](https://swe.quest/tags/sqlite.md?difficulty=easy))
- service discovery

## Keywords

Corrosion, cr-sqlite, SWIM, Consul, QUIC, Antithesis, OSPF, Fly.io

## Related posts

- [parking\_lot: ffffffffffffffff...](https://swe.quest/articles/parking-lot-ffffffffffffffff-e7cd36eac4ddf5cc.md): Fly.io · 2025-05-28 · Hard · 16 min read · Concurrency, Rust, Debugging, Incidents & postmortems, Load balancing
  Fly.io's Rust Anycast router, fly-proxy, kept deadlocking after Catalog state was moved to lazy loading.
- [Skip the API, Ship Your Database](https://swe.quest/articles/skip-the-api-ship-your-database-848af5fd83020408.md): Fly.io · 2023-09-13 · Medium · 5 min read · SQLite, API design, Replication, Multi-tenancy, System design
  Instead of designing an API for internal services, Fly.io ships them a read-only SQLite replica via LiteFS, letting consumers query and join data with plain SQL.
- [Throwing Out The Phonebook](https://swe.quest/articles/throwing-out-the-phonebook-38542538ac98046f.md): Fly.io · 2026-11-13 · Hard · 10 min read · Networking, Linux, Distributed systems, Deployment, System design
  Fly.io rebuilt 6PN, its private IPv6 network between Fly Machines, replacing a fleet-wide eBPF map of every migrated Machine's location (hundreds of thousands of entries kept in sync from Corrosion's gossip-replicated SQLite) with lazy, on-demand routes.
- [Lights Out, Systems On: Validating Instant Power Loss Readiness](https://swe.quest/articles/lights-out-systems-on-validating-instant-power-loss-readiness-42bc3b3cf0afa4b0.md): Meta Engineering · 2026-06-03 · Easy · 6 min read · Chaos engineering, Datacenters, Resilience, SRE
  Instantaneous PowerLoss Storm is Meta's disaster-readiness exercise that cuts power to an entire data center region with zero notice, then validates that storage, compute and the Twine orchestrator can bootstrap autonomously.
- [How we use formal modeling, lightweight simulations, and chaos testing to design reliable distributed systems](https://swe.quest/articles/how-we-use-formal-modeling-lightweight-simulations-and-chaos-testing-to-design-aca03cf9b6abf48d.md): Datadog Engineering · 2024-11-20 · Hard · 23 min read · Formal methods, Queues & messaging, Distributed systems, Chaos engineering, Multi-tenancy
  Datadog validated the design of Courier, a multi-tenant message queue built on multiple FoundationDB clusters after its March 2023 outage, by combining TLA+ formal modeling, lightweight simulations and chaos testing.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
