ChloeDB
Laptop to cloud

Start with a file. Add machines when you need them.

A shard is a ChloeDB file, a server serves one, and a cluster is servers behind a coordinator. Each step adds a process, never a new query language or a migration.

Five steps, and the app changes one line

Pick a step to see what you run, and what changes in the app.

import chloedb
db = chloedb.open("shop.chloedb")
db.query("SELECT id, title FROM products WHERE MATCH(title, :q) LIMIT 10",
         q="racing wheel")
chloedb-server --db shop.chloedb --listen 127.0.0.1:7700
db = chloedb.connect("http://127.0.0.1:7700")  # was chloedb.open(...)
db.query("SELECT id, title FROM products WHERE MATCH(title, :q) LIMIT 10",
         q="racing wheel")
chloedb-server --db shop.chloedb --seq-no \
  --replicas http://b:7701,http://c:7701 --failover-after-ms 3000
db = chloedb.connect("http://a:7700")           # the primary
db.insert({"id": "r9", "usr": "u7", "item": "B0C1", "stars": 5}, table="reviews")
chloedb-server --shards http://s0:7701,http://s1:7701 \
  --listen 127.0.0.1:7700 --grpc off
db = chloedb.connect("http://127.0.0.1:7700")  # the coordinator
db.query("SELECT id, title FROM products WHERE MATCH(title, :q) LIMIT 10",
         q="racing wheel")                      # asks every shard
db.get("B0C1", table="products")                # asks only the key's shard
kubectl apply -f operator.yaml -f cluster.yaml
kubectl -n strata patch strata demo --type merge \
  -p '{"spec": {"shards": 3}}'                  # slots move while it serves
db = chloedb.connect("http://demo.strata:7700")  # the cluster's Service
Watch it work

A search, a write, a failover and a new shard

Press a button, or let it play. Searches ask every shard and merge; a write goes to the one shard its key hashes to; a stopped primary is replaced by a vote; a new shard takes slots while the cluster serves.

An animation of what the coordinator and the copies do, slowed down to be seen; it is not connected to a cluster. The flags it names are chloedb-server's own.

What stays the same at every step

The SQL

Over shards, the coordinator's merge gives what one database gives, scores and limits included. Graph queries and INSERT … ON CONFLICT still need one database.

The schema

Tables, models, rank profiles and synonyms travel with the data.

The file format

A shard is a ChloeDB file. A checkpoint of one opens on a laptop.

The clients

chloedb.open and chloedb.connect have the same methods.

The command center

The same console for one server and for a cluster.

The tests

A deterministic simulator replays failovers and slot moves from a seed.

Laptop and cloud

The cluster on your laptop is the one in production

On kind it has the same pods, operator and resource as on EKS or DigitalOcean. Only the image, the storage and the sizes change.

git clone https://github.com/chloetech-ai/chloedb && cd chloedb
deploy=chloedb-server/deploy
$deploy/kind-test.sh up          # a kind cluster in Docker
$deploy/kind-test.sh image       # build the server image, load it
$deploy/kind-test.sh operator    # operator + 2 shards, until Ready
kubectl -n strata port-forward svc/demo 7700   # API and UI
$deploy/kind-test.sh scale 3 3   # a third shard; slots move live
cluster.yaml: laptop → cloud
  kind: StrataCluster
  spec:
-   image: chloedb-server:dev
+   image: ghcr.io/chloetech-ai/chloedb-server:latest
    shards: 2
    replicas: 3
    storage:
-     size: 1Gi
+     size: 200Gi
+     storageClassName: gp3    # do-block-storage on DigitalOcean
    resources:
-     requests: {cpu: 500m, memory: 1Gi}
+     requests: {cpu: "4", memory: 16Gi}
The command center's Cloud view can also plan, price and create the cluster for you.

Move a file to a cluster

Export the file's tables and import them through the coordinator, which places every row on its shard. Then point the app at the coordinator.

chloedb-server export --db shop.chloedb shop.sqlite
curl -s -X POST 'localhost:7700/v1/import?format=sqlite' \
  -H 'content-type: application/vnd.sqlite3' --data-binary @shop.sqlite