ticketmesh

- Backend Engineer
- November 2026
- In Progress
In numbers
- Holds for 500 buyers on 100 seats in a k6 flash sale; the other 400 got a clean conflict
- 100
- Hold p99 at 200 holds per second for 60 s, with 0 errors
- 3.59ms
- Holds per second sustained, 0 failed out of 109,497 requests
- 600
- A month on GCP by the free-tier cost table (Terraform not applied yet)
- 0.12USD
About the Project
ticketmesh is the backend of a ticket shop on the day a big show goes on sale: thousands of buyers want the same seats in the same minute, and no seat may ever be sold twice. It covers the whole path, from browsing events to holding seats, paying and being told the result, split into seven services in Go, Python and TypeScript.
Every request enters through a gateway with a per-IP rate limit, a circuit breaker per service and a deadline that the rest of the path honours. Behind it, each service listens only on loopback, and an auth sidecar written for the project is the one place that turns an RS256 token into an identity. Seats are held in Postgres with one conditional update and ordered row locks. Orders takes the hold over gRPC with a service token, and payment runs as a saga on events: a transactional outbox in every producer, an inbox in every consumer, retries with backoff and a dead-letter queue, and a refund when money arrives for a hold that was lost. The buyer hears the outcome over a WebSocket opened with a single-use ticket, and one OpenTelemetry trace follows a checkout across every service and the broker.
I built it in November 2026 to practise distributed systems end to end and to measure each claim instead of asserting it. In a k6 flash sale, 500 buyers on 100 seats got exactly 100 holds, and 200 holds per second ran at a p99 of 3.59 ms. Locally the broker is NATS JetStream. On GCP the Terraform runs every service on Cloud Run, scaling to zero, with Pub/Sub push instead of NATS, Postgres on the free VM and Firestore for documents. It is tested on mock providers in CI and not applied yet.
How it works
The path a request takes, step by step.
- BuyerHolds seats and pays with a token
- GatewayRate limit per IP, a breaker per service, deadlines
- Auth sidecarRS256 token to identity; the service is on loopback
- OrdersIdempotency key, seats held over gRPC
- Event busOutbox → NATS or Pub/Sub → inbox
- Payments and notifierThe saga settles; the buyer hears it over a WebSocket
Decisions
The choices that shaped it, and what each one cost.
Seat holds in Postgres, no Redis
- One source of truth for seats. The agreed rule was to add Redis only if 200 holds/s missed a 300 ms p99; it ran at 3.59 ms, and Postgres used 21% CPU.
- Measured on a laptop; the free GCP VM is much smaller, so the test must run there before a real sale.
Authorization only in a sidecar
- Every service binds to loopback, so the sidecar is the one place that turns a credential into an identity. It is tested against alg=none, algorithm confusion and spoofed headers.
- An extra hop per request: under load the sidecar checking tokens was the busiest container (26% CPU).
A saga on events, not a distributed transaction
- Payments charges outside its transaction and records the result through an inbox; orders applies each event under the order's row lock, so duplicates and races settle once.
- More states to reason about (refunding, expired), and outcomes are eventual.
Pub/Sub push on GCP instead of NATS
- Services scale to zero on Cloud Run, which a pull consumer cannot survive, and the one free VM already holds Postgres.
- Two transports to keep: the e2e suite covers only NATS, and the notifier runs as one instance on GCP.
