cloudparts

FoundationDB, CockroachDB or TiDB?

DimensionFoundationDBCockroachDBTiDB
In one lineA distributed, ordered key-value store with strictly serializable transactions, meant as a base for other databasesA distributed SQL database that speaks the PostgreSQL wire protocol, with every node doing everythingA distributed SQL database that speaks the MySQL protocol, split into SQL, storage and coordination services
What you talk toClient libraries (C, Python, Java, Go and others) that read and write keys inside transactions; no query language, schema or secondary indexes in the coreSQL from psql and PostgreSQL drivers and ORMs, through any nodeSQL from MySQL clients, drivers and ORMs, through stateless TiDB servers behind a load balancer
SQLOnly through layers, such as the FoundationDB Record Layer’s SQL interface over JDBCPostgreSQL-compatible, with gaps: no range types, foreign data wrappers or column-level privilegesCompatible with common MySQL 5.7 and 8.0 syntax, but no stored procedures, triggers, events or user-defined functions
How the cluster is builtSeparate roles: coordinators, a cluster controller, a sequencer, proxies, resolvers, transaction logs and storage servers, scaled independentlyOne cockroach binary per node; each node runs the SQL layer and stores replicas of some rangesTiDB servers for SQL, Placement Driver (PD) for metadata and timestamps, TiKV for row storage, optional TiFlash for columns
ReplicationCommits are fsynced by the transaction logs, then pulled by storage servers; on failure the cluster recruits a new transaction system rather than votingRaft per range of up to 512 MiB, three replicas by default; a leaseholder serves reads and coordinates writesRaft per Region of 256 MiB by default in TiKV, three replicas; TiFlash copies data as asynchronous Raft learners
Ordering transactionsA single sequencer hands out read and commit versionsHybrid logical clocks over NTP; a node whose clock drifts past the maximum offset (500 ms) shuts itself downA central timestamp oracle (TSO) in PD: a physical millisecond time plus a logical counter, per transaction
Concurrency controlOptimistic: resolvers check the read set at commit, and a conflicting transaction fails with not_committed and is retried by the clientMVCC with serializable checks; conflicts surface as retry errors (SQLSTATE 40001) the application must handle, unless the transaction arrives as one batchMVCC with a Percolator-style two-phase commit; pessimistic locking by default since v3.0.8, optimistic mode available
Default isolationStrict serializability for every transactionSERIALIZABLE; READ COMMITTED since 23.2Snapshot isolation, reported as REPEATABLE READ, which allows write skew; READ COMMITTED in pessimistic mode
AnalyticsNone built in; range reads over ordered keysRow store; changefeeds stream changes to Kafka, Pub/Sub, cloud storage or webhooks for analysis elsewhereTiFlash column replicas answer analytical queries on the same data, with snapshot-consistent reads
Hard limits and gotchasTransactions last at most 5 seconds and touch at most 10 MB; keys up to 10 KB, values up to 100 KB; no access controlRetry loops for 40001; cross-region writes pay quorum round trips; licence key and telemetry needed for free production useTransactions up to 100 MB by default (configurable to 1 TB) and rows up to 6 MiB; every transaction asks PD for timestamps; no spatial indexes and limited FULLTEXT
LicenceApache 2.0, maintained by AppleProprietary CockroachDB Software License since v24.3 (November 2024); free Enterprise for businesses under $10 million revenueApache 2.0, maintained by PingCAP

Rule of thumb

These sit at different levels. FoundationDB is the transactional engine you build a database on, as Apple and Snowflake did; pick it only if you’re writing that layer yourself and can live with 5-second transactions. Between the two SQL databases, start from the protocol your applications already speak: TiDB for MySQL, CockroachDB for PostgreSQL. CockroachDB gives serializable isolation by default and runs as one binary that is easy to spread across regions, but it is no longer open source. TiDB is Apache 2.0, separates SQL, storage and analytics so each can scale on its own, and adds column replicas for reporting, at the cost of more components to run and weaker default isolation.

Sources