Votee — Measured performance and recovery
All numbers were measured on one Apple Silicon laptop running everything at once: PostgreSQL 17,
Kafka and Redis in Docker, voting-api, outbox-relay, ranking-projector and the load
generator. They show relative behaviour and invariants, not production capacity.
Reproduce:
make infra-up && make migrate && make kafka-topics && make build
VOTEE_INTERNAL_API_ENABLED=true VOTEE_RATE_LIMIT_PER_SEC=0 VOTEE_DB_MAX_CONNS=40 VOTEE_CREDIT_URL= voting-service/bin/voting-api &
voting-service/bin/voting-worker outbox-relay &
voting-service/bin/voting-worker ranking-projector &
voting-service/bin/voting-load -concurrency 64 -duration 20s -actors 5000 -retry-every 10
voting-service/bin/voting-worker ranking-reconcile -campaign <printed campaign id>
Scenario 1 — uniform free votes with a retry storm
64 clients, 5,000 actors, 10 candidates, every 10th request re-sent with the same key.
| Metric | Value |
|---|---|
| Requests | 67,888 in 20.0 s (3,392 req/s) |
| Latency | p50 16.8 ms · p95 24.3 ms · p99 63.5 ms · max 616 ms |
| Accepted votes in the database | 61,741 |
Idempotent replays (Idempotent-Replayed: true) | 6,147 — exactly the re-sent requests |
votes = ledger entries = idempotency ACCEPTED | 61,741 = 61,741 = 61,741 |
| Deadlocks / serialization conflicts | 0 / 0 |
| Outbox after the run | 0 unpublished |
| Reconcile | 0 unapplied entries, 0 drift; Redis served the live ranking |
| Projector duplicates detected | 32 (redelivery around the group join), all ignored |
Where the vote transaction spends its time (pg_stat_statements, mean per call):
| Statement | Calls | Mean |
|---|---|---|
| Quota conditional upsert | 61,741 | 0.139 ms |
| Idempotency completion (UPDATE) | 61,741 | 0.114 ms |
| Idempotency claim (INSERT … ON CONFLICT) | 67,888 | 0.099 ms |
| Ledger insert | 61,741 | 0.105 ms |
| Vote insert | 61,741 | 0.056 ms |
| Outbox insert | 61,741 | 0.041 ms |
| Campaign + candidate snapshot read (one statement) | 61,741 | 0.038 ms |
| Projector: mark applied entries (batched) | 164 batches | 4.5 ms |
Server-side SQL is ~0.6 ms per vote; the rest of the 17 ms median is round trips, commit (WAL flush) and queueing on a laptop shared with the load generator. The projector handles ~380 entries per batch, so 61,741 votes cost only 164 projection transactions.
Possible next steps (not needed at this scale): fold the idempotency claim/complete into one
statement with the vote insert, or use synchronous_commit = off for the projector only (it
is rebuildable; votes are not).
Scenario 2 — hot candidate and quota contention
64 clients, 200 actors with a quota of 20 free votes each, 90 % of votes on one candidate.
| Metric | Value |
|---|---|
| Requests | 67,015 in 15.1 s (4,443 req/s) |
| Latency | p50 12.5 ms · p95 18.2 ms · p99 32.6 ms |
| Accepted (fresh) | exactly 4,000 = 200 × 20; every actor has exactly 20 votes |
| Rejected | 62,646 QUOTA_EXCEEDED (stored and replayed for retries) |
Σ quota.used | 4,000; max per actor 20 |
| Deadlocks | 0 |
Each actor's quota row is a hot row for that actor only: 64 concurrent clients over 200 actors serialize on the conditional upsert and never exceed the limit. The hot candidate does not create a hot row in the vote path because candidate totals are not maintained synchronously (the projector aggregates per batch).
Scenario 3 — chaos while voting
32 clients for 30 s; during the run:
| t | Fault |
|---|---|
| 5 s | kill -9 ranking-projector |
| 10 s | projector restarted |
| 12 s | kill -9 outbox-relay |
| 16 s | relay restarted |
| 18 s | Redis container stopped |
| 24 s | Redis started |
| Result | Value |
|---|---|
| Vote API | 100,968 requests, 100 % accepted, p99 17.7 ms — none of the faults touch the vote path |
| Votes / points in PostgreSQL | 91,801 / 91,801 |
| Projection after recovery | 91,801 points, 0 unapplied, 0 drift |
| Redis after recovery | 91,801 points (served from Redis) |
| Duplicates ignored by the projector | 221 (relay re-published the batch it was killed in; Kafka redelivered uncommitted records) |
Finding: after kill -9 the projection lagged for ~45 s. The dead member still owned its
partitions until its Kafka session expired (franz-go default 45 s); the restarted process could
not take them over earlier. The session timeout is now 15 s. A graceful stop (SIGTERM) leaves
the group immediately.
Cross-service smoke test
go test -tags smoke ./internal/smoke against campaign-service, credit-service, voting-api and
all workers passes in ~16 s: campaign creation and scheduling, snapshot sync, free and paid
votes, credit capture, insufficient credit, live ranking, early end, closing barrier,
FINALIZED with matching checksums, and a correction producing tally version 2 recorded by
campaign-service. Two behaviours of the eventually consistent manual END show up in practice:
- one probe vote sent right after END was still accepted (the ENDED snapshot reached Voting Core a few hundred milliseconds later); it is a legitimate accepted vote and is included in the final tally;
- the finalizer received FinalizationRequested before campaign-sync had applied the newer snapshot and retried once (~100 ms) instead of finalizing too early.