blog

SEAN K.H. LIAO

databases

People keep asking me career advice, here is one:

Make state someone else's problem.

Jaana Dogan (@rakyll) 2020-05-19

jepsen.io analyses arre imformative

basics

common-ish databases you might think about using

slight focus on distributed databases

isolation and consistency

Read isolation and consistency, and this and problems that may occur (the last table is a simple overview) tldr: it's confusing, moreso when transactions are involved

Simple way to think about it, add external consistency and stric serializable above serializable in isolation

CAP

Choose 2, only google can have CA

relational

The standard database.

embedded relational

not much choice here

database Language SQL syntax Isolation (default - max) License
SQLite C sqlite snapshot Public Domain
modernc.org/sqlite Go sqlite snapshot BSD 3
notes

single node relational

postgres is usually recommended

database Language SQL syntax Isolation (default - max) License
MariaDB C/C++ mysql snapshot - serializable GPLv2
PostgreSQL C postgres read committed - serializable PostgreSQL License
notes

multi node relational

database Language SQL syntax Operation modes CAP Isolation (default - max) Consensus License
CockroachDB Go postgres cluster CP serializable Raft Business Source License
dqlite C sqlite embedded CP ? Raft LGPLv3
Galera C/C++ mysql master-master - snapshot - serializable - GPLv2
rqlite C/Go sqlite cluster CP ? Raft MIT
Spanner ? spanner hosted CA external consistency Paxos -
Vitess Go mysql master-master - read committed - Apache 2.0
YugaByte DB C/C++ postgres cluster CP snapshot - serializable Raft Apache 2.0
notes

key value

Stores a blob of unindexed data.

embedded key value

database Language Isolation (default - max) License
badger Go snapshot Apache 2.0
bbolt Go serializable MIT
LevelDB C++ serializable BSD 3
goleveldb Go serializable BSD 2
LMDB C serializable OpenLDAP Public License
RocksDB C++ read committed - snapshot GPLv2
pebble Go snapshot BSD 3
notes

single node key value

database Language Isolation (default - max) License
Redis C serializable BSD 3
notes

multi node key value

database Language Operation modes CAP Isolation (default - max) Consensus License
Consul Go cluster CP strict serializable - external consistency Raft MPL 2.0
etcd Go cluster CP strict serializable - external consistency Raft Apache 2.0
FoundationDB C/C++ cluster CP Strict serializable Paxos Apache 2.0
ZooKeeper Java cluster CP read uncommitted - read committed Zab Apache 2.0
notes

document

Stores structured data (can be indexed). Can be used like a key-value store.

database Language Operation modes CAP Isolation (default - max) Consensus License
ArangoDB C++ cluster CP read uncommitted? Raft Apache 2.0
Couchbase C/C++/Erlang/Go master-master - read committed - Apache 2.0
CouchDB Erlang cluster PA snapshot - Apache 2.0
Fauna DB Scala cluster CP strict serializable Calvin -
Firestore - hosted CP external consistency - -
MongoDB C++ cluster CP read uncommitted - snapshot homegrown SSPL
RethinkDB C++ cluster CP read uncommitted - serializable Raft Apache 2.0
notes

wide column

Stores column data contiguously (as opposed to row data contiguously). Primary usecase is analytics.

database Language Operation modes CAP Isolation (default - max) Consensus License
BigTable - hosted CP row level atomic - -
Cassandra Java cluster CA row level atomic Paxos Apache 2.0
HBase Java cluster CP read committed Paxos Apache 2.0
notes

graph

Stores nodes and edges, super specialized.

database Language Operation modes CAP Isolation (default - max) Consensus License
Dgraph Go cluster CP snapshot Raft Apache 2.0
Neo4j Java cluster CP read committed Raft GPLv3
notes

time series

Write once, append only style. No transactions, no isolation concerns.

database Language Operation modes CAP Consensus License
Druid Java cluster - - Apache 2.0
InfluxDB Go cluster CA Raft MIT
OpenTSDB Java cluster CP Zab LGPL 2.1
TimescaleDB C single node - ? Apache 2.0
notes