You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: templates/keynote-2/DEVELOP.md
+3-186Lines changed: 3 additions & 186 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,8 @@ Copy `.env.example` to `.env` and adjust.
75
75
-`SKIP_SQLITE` – `1` = don't init SQLite in prep
76
76
-`SKIP_SUPABASE` – `1` = don't init Supabase in prep
77
77
-`SKIP_CONVEX` – `1` = don't init Convex in prep
78
-
-`SPACETIME_METRICS_ENDPOINT` – `1` = read committed transfer counts from the derived SpacetimeDB metrics endpoint; otherwise only local counters are used
78
+
79
+
Throughput is counted from successful operations that the benchmark client observes completing inside the configured test window for every connector, including SpacetimeDB.
pnpm run bench test-1 --connectors spacetimedb,sqlite_rpc
195
196
```
196
197
197
-
### 2. Run the distributed TypeScript SpacetimeDB benchmark
198
-
199
-
Use this mode when you want to spread explicit TypeScript client connections across multiple machines. The existing `pnpm run bench` flow is still the single-process benchmark; the distributed flow is a separate coordinator + generator setup.
200
-
201
-
The commands below are written so they run unchanged on a single machine. For a true multi-machine run, replace `127.0.0.1` with the actual coordinator and server hostnames or IP addresses reachable from each generator machine.
202
-
203
-
#### Machine roles
204
-
205
-
-**Server machine**: runs SpacetimeDB and hosts the benchmarked module.
206
-
-**Coordinator machine**: runs `bench-dist-coordinator` and `bench-dist-control`. It may also run one or more generators if you want.
207
-
-**Generator machines**: run `bench-dist-generator`. You can run multiple generator processes on the same machine as long as each one has a unique `--id`.
208
-
209
-
#### Distributed setup
210
-
211
-
All coordinator and generator machines should use the same `templates/keynote-2` checkout and have dependencies installed:
212
-
213
-
```bash
214
-
cd templates/keynote-2
215
-
pnpm install
216
-
cp .env.example .env
217
-
```
218
-
219
-
Generate TypeScript bindings in that checkout on each machine that will run the coordinator or a generator:
If you are using a named server instead of `local`, replace `--server local` with the correct server name.
249
-
250
-
#### Step 3: Start the coordinator
251
-
252
-
On the **coordinator machine**:
253
-
254
-
```bash
255
-
cd templates/keynote-2
256
-
257
-
pnpm run bench-dist-coordinator -- \
258
-
--test test-1 \
259
-
--connector spacetimedb \
260
-
--window-seconds 30 \
261
-
--verify 1 \
262
-
--stdb-url ws://127.0.0.1:3000 \
263
-
--stdb-module test-1 \
264
-
--stdb-compression none \
265
-
--bind 127.0.0.1 \
266
-
--port 8080
267
-
```
268
-
269
-
Notes:
270
-
271
-
- Before measurement begins, the coordinator waits for every participating generator to start its epoch and acknowledge that it is running.
272
-
-`--window-seconds` is the measured interval.
273
-
-`--verify 1` preserves the existing benchmark semantics by running one verification pass centrally after the epoch completes.
274
-
- If a generator never acknowledges start, the coordinator fails the epoch after `--start-ack-timeout-seconds` seconds. The default is `60`.
275
-
- The coordinator derives the HTTP metrics endpoint from `--stdb-url` by switching to `http://` or `https://` and appending `/v1/metrics`.
276
-
- For a real multi-machine run, change `--bind 127.0.0.1` to `--bind 0.0.0.0` so remote generators can reach the coordinator.
277
-
- For a real multi-machine run, set `--stdb-url` to the server machine's reachable address.
278
-
279
-
#### Step 4: Start generators on one or more client machines
280
-
281
-
On **generator machine 1**:
282
-
283
-
```bash
284
-
cd templates/keynote-2
285
-
286
-
pnpm run bench-dist-generator -- \
287
-
--id gen-a \
288
-
--coordinator-url http://127.0.0.1:8080 \
289
-
--test test-1 \
290
-
--connector spacetimedb \
291
-
--concurrency 2500 \
292
-
--accounts 100000 \
293
-
--alpha 1.5 \
294
-
--open-parallelism 128 \
295
-
--control-retries 3 \
296
-
--stdb-url ws://127.0.0.1:3000 \
297
-
--stdb-module test-1 \
298
-
--stdb-compression none
299
-
```
300
-
301
-
On **generator machine 2**:
302
-
303
-
```bash
304
-
cd templates/keynote-2
305
-
306
-
pnpm run bench-dist-generator -- \
307
-
--id gen-b \
308
-
--coordinator-url http://127.0.0.1:8080 \
309
-
--test test-1 \
310
-
--connector spacetimedb \
311
-
--concurrency 2500 \
312
-
--accounts 100000 \
313
-
--alpha 1.5 \
314
-
--open-parallelism 128 \
315
-
--control-retries 3 \
316
-
--stdb-url ws://127.0.0.1:3000 \
317
-
--stdb-module test-1 \
318
-
--stdb-compression none
319
-
```
320
-
321
-
Repeat that on as many generator machines as needed, adjusting `--id` and `--concurrency` for each process.
322
-
For a real multi-machine run, replace `127.0.0.1` with the coordinator host in `--coordinator-url` and the SpacetimeDB server host in `--stdb-url`.
323
-
324
-
`--open-parallelism` controls connection ramp-up only. It deliberately avoids a connection storm by opening connections in bounded parallel batches.
325
-
`--control-retries` sets the retry cap for `register`, `ready`, `/state`, and `/stopped`. The default is `3`.
326
-
327
-
#### Step 5: Confirm generators are ready
328
-
329
-
On the **coordinator machine**:
330
-
331
-
```bash
332
-
cd templates/keynote-2
333
-
334
-
pnpm run bench-dist-control -- status --coordinator-url http://127.0.0.1:8080
335
-
```
336
-
337
-
Wait until each generator shows `state=ready` and `opened=N/N`.
338
-
339
-
#### Step 6: Start an epoch
340
-
341
-
On the **coordinator machine**:
342
-
343
-
```bash
344
-
cd templates/keynote-2
345
-
346
-
pnpm run bench-dist-control -- start-epoch --coordinator-url http://127.0.0.1:8080 --label run-1
347
-
```
348
-
349
-
`start-epoch` waits for the epoch to finish, then prints the final result.
350
-
351
-
#### Step 7: Check results
352
-
353
-
Each completed epoch writes one JSON result file on the coordinator machine under:
354
-
355
-
```text
356
-
templates/keynote-2/runs/distributed/
357
-
```
358
-
359
-
The result contains:
360
-
361
-
- participating generator IDs
362
-
- total participating connections
363
-
- committed transaction delta from the server metrics endpoint
364
-
- measured window duration
365
-
- computed TPS
366
-
- verification result
367
-
368
-
#### Operational notes
369
-
370
-
- Start the coordinator before the generators.
371
-
- Generators begin submitting requests when the coordinator enters `starting`.
372
-
- Throughput is measured only from the committed transaction counter delta recorded after all participating generators have acknowledged start, so startup traffic is excluded.
373
-
- For this distributed TypeScript mode, each connection runs closed-loop with one request at a time. There is no pipelining in this flow.
374
-
- Late generators are allowed to register and become ready while an epoch is already running, but they only participate in the next epoch.
375
-
- The coordinator does not use heartbeats. It includes generators that most recently reported `ready`.
376
-
- If a participating generator dies and never sends `/stopped`, the epoch result is written with an `error`, and that generator remains `running` in coordinator status until you restart it and let it register again.
377
-
- You can run multiple generator processes on the same machine if you want to test the harness locally. Just make sure each process uses a unique `--id`.
Copy file name to clipboardExpand all lines: templates/keynote-2/README.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,8 +35,6 @@ All tests use 50 concurrent connections with a transfer workload (read-modify-wr
35
35
36
36
**Key Finding:** SpacetimeDB achieves **~14x higher throughput** than the next best option (SQLite RPC) and maintains nearly identical performance under high contention (only ~4% drop), while traditional databases suffer significant degradation (CockroachDB drops 96%).
37
37
38
-
> **Note:** SpacetimeDB runs on ARM architectures (including Apple M-series Macs), but has not yet been optimized for them.
0 commit comments