How it’s built
What is real, what is simulated, and where the prototype ends
The prototype was made for the EPS practical test. Everything runs on one VPS: a host Caddy for TLS, in front of a Docker Compose stack with the app, the worker, the simulator, Postgres and Redis.
Architecture
What is real and what is simulated
| Part | Real | Simulated |
|---|---|---|
| Queue, holds, inventory | The full code: the lottery, the Redis Lua scripts, the Postgres orders, the limits. | Nothing. |
| The arena crowd | Every request goes through the app’s queue, agent gate and checkout. | The people: 100,000 arrivals played by the simulator on the same VPS. |
| HTTP load | k6 runs against the VPS, recorded in docs/load-results.md. | The clients: one k6 machine plays thousands of distinct clients. |
| Payments | The state machine, the failover from A to B, reconciliation and refunds. | Providers A and B are mocks: no money, no card network. |
| AI (assistant, engine explanations) | A real model, through the local bridge to the owner’s Claude subscription. | When the bridge does not answer: scripted replies from templates. |
| AI agents | Web Bot Auth signatures are verified. | The agents in the arena are signed by the simulator. |
What was measured
Load tests (k6)
Read now from docs/load-results.md, one row per run.
| Run | Date | Server | k6 machine | Arrivals/s peak | Arrivals/s mean | Queue wait p50 ms | Queue wait p95 ms | Purchases/s | Payment recovery p50 ms | Payment recovery p95 ms | Payment recovery max ms | Oversold | Double charges |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Run 1: CI-sized, local (load.js), 2026-11-29 | 2026-11-29 | none. Local stack in a 4 vCPU (Intel Xeon @ 2.10 GHz) / 15 GB container. next start + worker + Postgres 16 + Redis on the same box. For comparison, the production target is the shared 4 vCPU / 7.8 GB VPS. | the same container (k6 v2.4.0), so k6 competed with the app for the 4 vCPUs | 20 | 6.35 | 18,015 | 21,022 | 5.07 | 527 | 1,037 | 1,052 | 0 | 0 |
Latest arena run (simulated crowd)
Finished 29 Nov 2026, 15:25. Simulated crowd, real code paths. HTTP capacity is measured separately with k6.
- Oversold
- 0
- Duplicate charges
- 0
- Arrived
- 100,000
- Tickets sold
- 39,019
- Revenue
- 16,937,486 lei
- Bots blocked
- 22,539
- Checkout p95
- 2,437 ms
- Arrivals per second (peak / mean)
- 556 / 166.67
- Wait in the line (p50 / p95)
- 268.1 s / 469.9 s
- Purchases per second
- 28.08
- Payment recovery (p50 / p95)
- 3.2 s / 6.9 s
Known limits
This is where the prototype ends. Nothing below is solved.
- The lottery is only as fair as an identity is hard to fake. A cookie is free: someone who opens many browsers or clears their cookies gets more places in the draw. Per-IP limits slow this down; they do not stop it. (Q-11)
- Email and phone are not verified. The per-person ticket limit counts normalised email addresses and phone numbers, so someone with several of each can get around it. (LIM-5)
- The ticket code rotates every 15 seconds, so a screenshot does not get through the door. It does not stop a person who forwards the live ticket page to someone else. (QR-9)
- One VPS, no redundancy: if the machine goes down, the site goes down. A watchdog restarts the stack after two failed checks, nothing more.
- Identities are unverified: no ID check, no account. Anyone can be anyone.
- Payments go to the mock providers A and B: no real processor, no card network, no real money.
- The AI runs through a local bridge to the owner’s Claude subscription. When the bridge is down or busy, a scripted fallback answers: templates, not a model.
- The arena crowd runs on the same VPS: it shows the code paths, not the capacity. HTTP capacity is only what k6 measured.
What changes for production
- The queue at the edge: the waiting room is served by the delivery network, and the origin only sees admitted fans.
- Several regions, with failover between them.
- Managed Postgres with replicas and point-in-time recovery; Redis with a replica.
- A payment orchestrator with network tokens, so a fan does not retype a card when the payment fails over to another processor.
- Romanian acquirers and settlement in RON.
- Verified identity before the lottery, so one person gets one place.