Skip to content
clientdb

Search the docs

Find a page or section

Reference

Benchmarks

Scale, server, socket-free, Prisma and client numbers: single machine, local Postgres 16, Node 22.

Everything runs on one machine with no network latency, so the numbers measure engine and database work, not the network. All of them were measured on the same 4-core VM (16 GB, Node 22, Postgres 16 on the same machine), except the previous core's numbers in parentheses in the client table, which are recorded in bench/baseline/. Throughput is bounded by the single local Postgres and varies by roughly ±10% between runs.

At scale: Prisma writes fanned out to thousands of clients

CLIENTDB_TEST_PG=… yarn bench:scale (bench/scale/, described in bench/README.md): an issue tracker in Prisma-managed tables with capture triggers and a defineRule membership rule (a viewer reads the teams it belongs to; every user is in two of 200 teams). Writers (55% issue updates, 30% new comments, 10% new issues, 5% both in one transaction) go through Prisma Client at a fixed rate; the sync server runs engine.start(); simulated clients speak the wire protocol from separate processes, and 20 real clients with full replicas confirm the simulated latencies (p50 / p99 3.2 / 6.2 ms simulated, 3.3 / 6.6 ms real at 300 writes/s).

Everything shares one 4-core VM (16 GB) with Postgres 16: shared_buffers 2 GB, random_page_cost 1.1, synchronous_commit and fsync on. Commit → visible is from the writer's commit to the client receiving the change, on loopback. 10,000 users, 130,000 rows, ~1,400 rows per viewer unless noted.

Write rate, 1,000 WebSocket clientsCommit → visible p50 / p95 / p99Server CPUPostgres CPU
300 writes/s3.3 / 5.3 / 6.6 ms26%57%
1,000 writes/s6.2 / 8.8 / 10.2 ms41%88%
3,000 writes/s20.3 / 31.9 / 48.9 ms50%128%
5,000 writes/s (saturated: 4,297 achieved)70.6 / 106 / 122 ms52%150%

CPU is in percent of one core. Postgres is the limit, at about 4,300 Prisma writes/s on this machine.

Connected clients, 300 writes/sCommit → visible p50 / p99Server CPU
1,000 WebSocket3.2 / 6.1 ms25%
10,000 WebSocket4.0 / 12.4 ms50%
20,000 WebSocket10.7 / 23.6 ms77%
5,000 polling over HTTP every 5 s2.6 / 5.0 s56%
10,000 polling every 5 s3.0 / 5.9 s87%
OtherResult
1,000 clients bootstrapping at once (~1,300 rows each)8.4 s; 3.4 s with MemorySnapshotStore
One bootstrap, warm database / first after a fresh database copy50–60 ms / ~1.1 s
300 writes/s with 24,000 rows per viewer (500 members per team, 30,000 deliveries/s)p50 / p99 3.9 / 8.0 ms
1m-row tables, same rows per viewer: 300 / 3,000 writes/s, p503.1 / 17.8 ms
10m-row tables, same rows per viewer: 300 / 3,000 writes/s, p503.3 / 21.5 ms
Adopting existing rows (engine.migrate()): 1m / 10m rows84 s / 9.1 min

Server

CLIENTDB_TEST_PG=… yarn bench:server: the issues example with 20,000 visible and 5,000 hidden issues in one team. One admin and one member client are connected.

MetricResult
Seeding through the engine (routing + outbox, 500 rows/tx)4,214 rows/s
Cold bootstrap in process, admin (25,000 issues)195.8 ms
Cold bootstrap in process, member (20,000 issues)134.8 ms
HTTP NDJSON bootstrap into a client, admin: cold / warm snapshot cache198.2 / 78.3 ms
Write latency (permission checks + routing + outbox), p50 / p991.70 / 3.90 ms
Commit → visible on another client (WebSocket), p50 / p992.63 / 5.49 ms
Throughput, background sequencer, 16 concurrent writers: committed / delivered1,965 / 1,962 tx/s
Catch-up after 1,000 changes offline (WebSocket reconnect)7.6 ms
Promote → all 5,000 hidden issues usable on the member's client51.6 ms
Demote → hidden issues evicted18.7 ms
Hide one issue → move-out on the member's client3.9 ms
Hide an issue with 2,000 comments: per-row re-route / set-based subtree re-tag63.5 / 43.2 ms

Socket-free mode

No engine.start(), sequencing inline in requests. Measured through the fetch-standard handler (the same code the Next.js route handlers use).

MetricResult
Push of one transaction incl. inline sequencing, p50 / p992.69 / 4.43 ms
Pull with nothing new, p50 / p991.01 / 1.95 ms
Push + pull in one request, p50 / p993.76 / 5.58 ms
Pull after 1,000 changes (compacted, streamed)12.9 ms, 273 KB
Throughput, 8 concurrent serverless instances1,184 tx/s

Inline sequencing passes are serialized by a transaction-scoped advisory lock (that keeps ids in commit order), which caps throughput below the background sequencer.

Prisma-managed tables

yarn bench:prisma: ShareKit's schema and permissions on engine-owned tables vs Prisma's tables; 10,000 uploads with one file each in one team.

MetricEngine-owned tablesPrisma-managed tables
Bootstrap of a team member (20,000 rows)254.9 ms273.2 ms
Client update, confirmed, p50 / p992.76 / 4.36 ms3.46 / 7.78 ms
Client create until sequenced, p500.98 ms3.35 ms
Adopting 20,000 existing rows (engine.migrate())n/a1.61 s
App write with Prisma, p50: plain / with engine.changedn/a1.31 / 5.25 ms

On Prisma tables each write also updates a side-table row and each read joins it, about 0.5 to 1 ms per write.

Client

yarn bench (Node 22, --expose-gc). 100 owners and N dogs with 4 fields, indexed by ownerId. Numbers for the previous MobX-based core in parentheses.

BackendRowsIngest µs/rowCreate µs/rowHeap B/rowFirst indexed query ms100 indexed queries msObserved field write µs
signals10,0000.819.39 (30.98)209 (8,531)3.89 (18.8)1.25 (22.9)12.1
signals50,0000.509.25 (30.47)193 (8,517)0.09 (116.8)7.35 (372.8)10.8
signals100,0000.8810.05 (26.61)193 (4,321)0.15 (236.5)12.2 (1,499.5)16.1
mobx10,0000.5010.99 (30.98)203 (8,531)0.08 (18.8)5.32 (22.9)11.2
mobx50,0000.7310.45 (30.47)193 (8,517)0.21 (116.8)11.4 (372.8)10.9
mobx100,0001.0710.92 (26.61)193 (4,321)0.21 (236.5)16.4 (1,499.5)23.8
  • Ingest is the bootstrap path: rows as arrays, no entity objects.
  • Create is an optimistic local create: a transaction, an outbox entry and an undo record per call.
  • Observed field write is one assignment while an effect observes the field and a collection filtering on that column. Observed queries are maintained incrementally (O(log n) per affected query).

Running them

Terminal
yarn bench                                  # client
CLIENTDB_TEST_PG=postgres://… yarn bench:server
CLIENTDB_TEST_PG=postgres://… yarn bench:prisma
CLIENTDB_TEST_PG=postgres://… yarn bench:scale   # DATASET=1m|10m|wide, SUITES=rate,clients,poll,bootstrap,full