> ## Documentation index
> Fetch the complete documentation index at: https://goncordia.docs7.io/llms.txt
> Ask it with GET https://goncordia.docs7.io/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.

# Benchmarks

> Throughput and latency by backend

```
go test ./bench/... -bench=. -benchmem -benchtime=5s -timeout=15m
```

Apple M5, single process. Memory/SQLite are in-process (no network); Postgres/MongoDB/Redis run in Docker on localhost.

**Enqueue — single job**

| Backend | ns/op | Notes |
|---|---|---|
| Memory | 0.57 µs | in-process mutex, no I/O |
| SQLite | 27 µs | WAL mode, single connection |
| Redis | 109 µs | ZADD over localhost |
| Postgres (pgx v5) | 129 µs | INSERT over localhost |
| MongoDB | 338 µs | insertOne over localhost |
| DynamoDB | 632 µs | PutItem over localhost |
| Firestore | 1 195 µs | RunTransaction + Create over emulator |
| ClickHouse | 1 378 µs | INSERT + new data part over localhost |
| Cassandra | 7 216 µs | LWT requires Paxos quorum (3 round trips) |

**EnqueueBatch(100) — 100 jobs per call**

| Backend | ms/batch | jobs/s |
|---|---|---|
| Memory | 0.06 ms | ~1 775 000 |
| SQLite | 2.8 ms | ~35 300 |
| Redis | 10.9 ms | ~9 200 |
| Postgres (pgx v5) | 12.8 ms | ~7 800 |
| MongoDB | 34.9 ms | ~2 900 |
| DynamoDB | 62.9 ms | ~1 590 |
| Firestore | 93.5 ms | ~1 070 |
| ClickHouse | 150 ms | ~665 |
| Cassandra | 708 ms | ~141 |

**FetchAndComplete — hot worker loop path**

| Backend | µs/op | Notes |
|---|---|---|
| SQLite | 53 µs | indexed; faster than memory at scale |
| Memory | 520 µs | O(N) linear scan |
| Redis | 729 µs | Lua ZPOPMIN + HSET |
| DynamoDB | 1 731 µs | Query GSI + conditional UpdateItem |
| MongoDB | 2 475 µs | findAndModify + updateOne |
| Postgres (pgx v5) | 12 190 µs | SELECT SKIP LOCKED + UPDATE |
| ClickHouse | 14 416 µs | SELECT FINAL + INSERT new version |
| Cassandra | 18 813 µs | SELECT avail + LWT UPDATE per job |
| Firestore | 140 943 µs | Query + per-job RunTransaction on emulator |

**End-to-end — full WorkerPool**

| Backend | workload | concurrency | jobs/s | Notes |
|---|---|---|---|---|
| Memory | 1 000 | c=10 | ~2 020 | |
| Redis | 1 000 | c=4 | ~1 084 | Pub/Sub notifications |
| SQLite | 1 000 | c=4 | ~800 | |
| DynamoDB | 1 000 | c=4 | ~780 | polling; GSI query overhead |
| MongoDB | 1 000 | c=4 | ~452 | Change Streams |
| Postgres (pgx v5) | 1 000 | c=4 | ~179 | LISTEN/NOTIFY |
| Cassandra | 1 000 | c=4 | ~153 | polling; LWT overhead |
| ClickHouse | 1 000 | c=4 | ~148 | polling; SELECT FINAL overhead |
| Firestore | 200 | c=4 | ~14 | polling; per-job RunTransaction on emulator |

End-to-end throughput is bounded by the 5 ms poll interval used in the benchmark. In production the pgxv5 driver uses LISTEN/NOTIFY and the Redis driver uses Pub/Sub, eliminating poll latency entirely — real throughput matches the FetchAndComplete numbers above.

Cassandra's high per-operation latency comes from Lightweight Transaction consensus (Paxos, ~3 network round trips per claim). ClickHouse's overhead comes from `SELECT … FINAL` deduplication at query time. DynamoDB's per-operation cost is dominated by HTTP/JSON round trips to the service — measured against DynamoDB Local on localhost, so real AWS numbers include additional network latency. Firestore's per-job `RunTransaction` for claiming is the primary bottleneck on the emulator; production GCP Firestore will be faster due to lower round-trip latency, but the sequential-per-job claiming model inherently limits throughput. All four backends are best suited for workloads where horizontal scale matters more than raw per-job latency.
