Latest / The CTO Podcast with Fexingo: Technical Leadership, Architecture, and Engineering Org / How CockroachDB Survived the Cloud Database Wars
Transcript
- Lucas: If these conversations are useful for what you're building or running, we're glad to have you along. Today we're looking at a database that was built to survive — literally. CockroachDB. The name is not a joke, it's the whole thesis: this thing should survive a nuclear war. Luna: And it almost didn't survive the cloud database wars. There was a moment around 2020 where everyone thought Cockroach Labs was going to get crushed by Google Spanner and AWS Aurora. Lucas: Right. So CockroachDB started in 2015, founded by ex-Google engineers Spencer Kimball, Peter Mattis, and Ben Darnell — the same team that built Google's Bigtable and later worked on Spanner. Their insight was that existing SQL databases couldn't scale horizontally, and NoSQL databases like Cassandra forced you to give up transactions. Lucas: So they built a distributed SQL database that used the Raft consensus protocol for replication. Raft is the simpler cousin of Paxos, the algorithm Google Spanner uses. It lets a cluster of nodes agree on a single source of truth even if some nodes fail. Luna: But Google had already solved that problem with Spanner. And Spanner ran on Google's own fibre network with atomic clocks for global time synchronization. CockroachDB didn't have that luxury. Lucas: Exactly. Spanner uses TrueTime, which gives you a tightly synchronized clock across data centres. CockroachDB had to do without. Instead they used hybrid logical clocks — HLC — which approximate causality without hardware assistance. It's clever, but it introduces a latency penalty for global writes. Lucas: Early benchmarks showed that a write spanning two continents could take 200 milliseconds, compared to maybe 10 milliseconds locally. That 20x latency gap was a dealbreaker for many apps. Luna: So how did they fix it? Because today CockroachDB powers companies like JPMorgan, which has strict compliance requirements for data residency. You can't have a write from London going to New York and back. Lucas: They introduced geo-partitioning in version 20.1, around mid-2020. The idea is simple: you can tell the database that rows with a certain region column must live on specific nodes. So a European customer's data never leaves Europe. Lucas: Under the hood, it's implemented as a SQL constraint on the table's partitioning scheme. The query planner uses that constraint to route reads and writes to the closest replica. Latency drops back to single-digit milliseconds for local operations. Luna: But doesn't that break the whole 'one logical database' promise? If data is physically siloed, you lose the ability to run global queries. Lucas: You can still run global queries — they just become slower. The trade-off is explicit. CockroachDB calls it 'survivability goals.' You can set a goal for regional survival, meaning you tolerate a whole region failing, or you set it for zone survival within a region. The geo-partitioning is an additional layer on top. Lucas: This was the turning point. Once they had geo-partitioning, financial services started paying attention. JPMorgan came on as a customer in 2021, and that gave Cockroach Labs the revenue traction to go public with an IPO filing in 2022. Luna: And then the market turned. 2022 was brutal for cloud infrastructure IPOs. They pulled the filing and stayed private. But they kept growing. Lucas: By 2023, they announced $50 million in annual recurring revenue. Not huge compared to Snowflake or Databricks, but respectable. And they did it without vc mandated growth at all costs — they actually had a path to profitability. Luna: What about the open-source licensing drama? CockroachDB was originally under a permissive Apache 2.0 license. Then in 2019 they switched to a modified version of the Business Source License, which restricts production use by competitors. Lucas: That was controversial. Some community members felt betrayed. But look at what happened to Redis Labs and MongoDB — they all went the same route. The argument is that cloud providers like AWS would package your open-source database as a managed service and capture all the value. Lucas: Cockroach Labs's CEO, Spencer Kimball, wrote a blog post explaining that the BSL change was necessary to preserve the company's ability to invest in the product. He cited that AWS was already offering a managed CockroachDB-like service based on the open-source code. Luna: Did it work? Did they keep the community? Lucas: Mostly. The core database engine is still open source in spirit — you can read the source, compile it, run it yourself. The enterprise features like geo-partitioning and backup are source-available but require a license. That's similar to what GitLab does. Lucas: The bigger risk wasn't the license change. It was the competitive landscape. In 2019, AWS launched Aurora Multi-Master, which claimed to support multi-region writes. Google Spanner became available as a managed service. Microsoft Azure Cosmos DB was already there. Luna: So how does CockroachDB differentiate today? Lucas: Three things. First, it's truly SQL. Not sql like, not a subset — full PostgreSQL wire protocol compatible. You can take an existing Postgres app and point it at CockroachDB with almost no changes. Luna: Second, it gives you strong consistency by default. Most distributed databases use eventual consistency because it's faster. CockroachDB uses serializable isolation, which is the strictest level — your reads always reflect the latest write, even across regions. Lucas: And third, the operational simplicity. CockroachDB has a built-in admin UI, automatic rebalancing of data across nodes, and a 'survival' dashboard that shows you exactly how many regions can fail before you lose availability. That's a huge selling point for teams that don't have dedicated database reliability engineers. Luna: It sounds like they've carved out a niche. But I'm curious about the architecture itself. How does Raft consensus work in practice for a global database? Lucas: So CockroachDB breaks data into ranges, each 64 megabytes by default. Each range is replicated three ways — that's the default replication factor. The replicas form a Raft group, and one replica is elected the leader. All writes go to the leader, which replicates them to the followers. Lucas: If the leader fails, the followers hold an election and pick a new leader. Raft guarantees that at most one leader is elected per term, so there's no split-brain. The whole process takes a few seconds. Luna: But what about read performance? If every read has to go through the leader, that's a bottleneck. Lucas: They solved that with follower reads. If your application can tolerate slightly stale data — and many can — you can configure CockroachDB to read from any replica, not just the leader. The trade-off is that the data might be a few milliseconds behind. But for local reads, it's often fine. Lucas: They also introduced a feature called 'global tables' in version 21.1. This is for small, read-heavy tables like country codes or currency exchange rates. The data is replicated to all regions, and reads are served from the closest replica without leader involvement. Writes are slower because they need consensus across all regions, but for infrequently updated data, it works. Luna: That's smart. But I remember reading that CockroachDB had a rough time with Google Cloud's internal adoption. Google engineers considered it but ultimately stuck with Spanner for their own products. Lucas: That's true. Google has a 'dogfood' policy — they use their own products. Spanner is battle-tested at Google scale. CockroachDB never had that internal validation from a company the size of Google. But that might have been a blessing in disguise — it forced them to focus on the mid-market and enterprise, where the buying criteria are different. Lucas: For a mid-size fintech or a retailer expanding into Europe, CockroachDB is a much easier sell than Spanner. Spanner requires you to buy into the entire Google Cloud ecosystem. CockroachDB runs on any cloud or on-premises. Luna: And the uptime guarantee? I've seen they claim 99.995 percent availability. Lucas: Right. That's about 26 minutes of downtime per year, across all regions. They back it with a service-level agreement that includes credits if you go below. For a distributed system that's multi-region, that's a strong claim. It's achievable because of the Raft replication — if one region goes down, the other two can still serve reads and writes. Luna: But there's a catch. The 99.995 percent only applies if you deploy across three regions. If you only use two regions, the guarantee drops. Lucas: Yeah, with two regions you can survive one region failure, but if the remaining region has a problem, you're down. The three-region topology is the sweet spot. And honestly, if you're building a global application, three regions should be the baseline. Luna: Let's talk about the development timeline. CockroachDB reached general availability in 2017, but it had been in development since 2015. That's two years. Then they added geo-partitioning in 2020. That's five years from start to the feature that unlocked enterprise sales. Lucas: Yeah, building a distributed database is not a weekend project. The Raft implementation alone took about a year to get right. And they had to rewrite the SQL layer multiple times to support full PostgreSQL compatibility. The first version could barely handle JOINs. Luna: And now, in 2026, where does CockroachDB stand? The cloud database market has consolidated. We have Snowflake for analytics, MongoDB for document stores, and CockroachDB for transactional SQL across regions. Lucas: I think they've found a defensible position. The key metric to watch is not just revenue but the number of production deployments with three or more regions. That's where the switching costs are highest. Once you've partitioned your data across the US, Europe, and Asia, moving to another database is a multi-year project. Lucas: Quick honest thing — a handful of listeners chip in monthly through buy me a coffee dot com slash fexingo, and that's literally what funds making this many of these. If you get value from the show, we'd be grateful for your support. Luna: Yeah, it's how we keep it ad-free and focused on the architecture decisions that matter. No sponsors, no fluff. Lucas: So back to CockroachDB — the question I keep coming back to is whether they can grow beyond financial services. They have a strong foothold in banking, but retail and gaming have different patterns. Gaming, for example, tends to have write-heavy workloads with lots of concurrent players. Luna: CockroachDB can handle high write throughput if you shard properly. But the consensus overhead means each write has to touch at least two nodes. For a game like Fortnite with millions of concurrent players, that could be a bottleneck. Lucas: Right. They've optimized for correctness and consistency over raw throughput. That makes them a great fit for payments, trades, and compliance workloads. But for use cases that can tolerate eventual consistency, Cassandra or DynamoDB might still be faster and cheaper. Lucas: The ultimate test for CockroachDB will be whether they can become the default operational database for multi-cloud deployments. If the industry truly moves toward multi-cloud, CockroachDB is one of the few options that works across AWS, GCP, and Azure without vendor lock-in. Luna: That's a big if. Most companies still pick one cloud. But the ones that don't — the JPMorgans, the large European banks — they need CockroachDB. Lucas: Exactly. And that's probably enough for a sustainable business. You don't need to be the default for everyone. You just need to be the default for the few thousand customers who absolutely cannot afford downtime or data inconsistency.