Corrosion: Gossip Based Service Discovery with SQLite and CRDTs
Service discovery is one of those problems that sounds simple until you try to do it in production. You need nodes to find each other, handle partitions, and converge on the same view of the world without a single point of failure. Most solutions reach for etcd or Consul, but what if you could get eventual consistency with just SQLite and CRDTs?
That's what Corrosion does, and it's surprisingly elegant.
What It Does
Corrosion is a gossip based service discovery tool built by the folks at Superfly (the Fly.io team). It uses a hybrid logical clock (HLC) and CRDT (Conflict-free Replicated Data Type) to let nodes share service information with each other over a simple UDP gossip protocol.
Each node stores its local service state in SQLite, and periodically gossips that state to a random set of peers. Because the state is a CRDT, conflicting updates (like two nodes claiming the same service name) are automatically resolved using the HLC timestamps. No master, no consensus, no Raft. Just gossip and merge.
The end result: every node eventually converges on the same set of services, even with network partitions or node failures.
Why It's Cool
There are a few things about this project that make it stand out:
SQLite as the single source of truth. Most gossip based systems store state in memory or some custom data structure. Corrosion stores everything in a local SQLite database. That means you can query it with standard SQL, you get persistence for free, and you can even do joins or other relational operations on service metadata.
CRDTs without the complexity. The gossip protocol itself is a CRDT. Nodes exchange state diffs, and because the state is designed to be merge-friendly, there's no need for expensive consensus. The HLC ensures that "last writer wins" makes sense even across nodes with slightly out of sync clocks.
Super simple API. The project exposes a tiny HTTP interface for registering and querying services. You don't need to install a control plane or run a sidecar. Just start Corrosion on each node, and services start appearing.
Built for edge and transient networks. Because it's gossip based, it handles nodes disappearing and reappearing gracefully. The team behind it uses it for Fly.io's internal infrastructure, which means it's tested against real world network chaos.
How to Try It
Getting started is dead simple. Corrosion is written in Go, so you can grab a binary from the releases page or build from source.
Clone the repo and build:
git clone https://github.com/superfly/corrosion
cd corrosion
go build .
Run a seed node:
./corrosion --addr :4000
Join a second node to the gossip network:
./corrosion --addr :4001 --seed localhost:4000
Register a service on the first node:
curl -X POST http://localhost:4000/services \
-d '{"name":"my-api","host":"10.0.0.1","port":8080}'
Query services from either node:
curl http://localhost:4001/services
You'll see both nodes eventually agree on the registered service. Disconnect the second node, register something new, reconnect, and watch it converge.
Check the GitHub repo for more detailed docs and configuration options.
Final Thoughts
Corrosion is a great example of picking the right tool for the job. Instead of building a complete consensus system or relying on an external database, they used SQLite (which is already everywhere) and a gossip layer with CRDT semantics. It's lightweight, easy to run, and surprisingly robust for its simplicity.
If you're running a small cluster, a home lab, or want to experiment with gossip protocols without reaching for a big distributed system, give this a try. It's one of those projects where you'll read the code and think, "Why didn't I think of that?"
Follow us on X: @githubprojects