Project: Iron Systems – From Locks to Actors
Goal: Build a production-flavored blueprint for high-concurrency distributed systems that demonstrates the Four Pillars of Performance:
- Parallel Reads (lock-free, cache-first)
- Serialized Writes (single writer per key/partition)
- Read/Write Separation (write path mutates truth; read path serves snapshots)
- Asynchronous State (event-driven consistency, replayable)
Deliver two implementations under one repo:
- Python/FastAPI +
aiokafka+redis+asyncpg - Go (Gin/Fiber) + Sarama (Kafka) + go-redis + pgx
The two versions should mirror the same architecture and behavior.
POST /reserveenqueues a reservation command keyed byslot_id.GET /slots/{id}returns remaining capacity from cache (Redis); supports Stale-While-Revalidate (SWR).- Worker consumes messages per partition, processes actor-style single writer, persists to PostgreSQL with idempotency, and refreshes cache.
- Unique constraints prevent duplicate reservations: a user may reserve a timeslot only once; a timeslot has a configurable capacity.
- Write path (enqueue → process → persist → cache refresh):
- ≥ 5,000 RPS sustained; P99 < 250ms end-to-end under normal conditions.
- Read path (cache hit):
- ≥ 50,000 RPS; P95 < 20ms.
- Read path (cache miss, SWR):
- ≥ 10,000 RPS; P95 < 60ms.
- Stability: 60-minute run without message loss; Kafka lag bounded and recovers after spikes.
- /metrics (Prometheus) exposes RED metrics (Rate/Errors/Duration) per service, plus:
- Kafka consume/produce rates & lag
- Worker batch size, flush latency
- DB TPS (optional), Redis hit ratio (optional)
- Tracing (OpenTelemetry) spans across API → producer → worker → DB (best-effort; if time is tight, keep hooks ready).
- Idempotency via request key (
Idempotency-Keyheader or(user_id, slot_id)unique pair) + DB constraints. - Retry with backoff for transient Kafka/Redis/DB errors.
- DLQ: if a message fails N times, route to dead-letter topic with reason; provide a manual replay script.
- Graceful shutdown: drain in-flight requests/records.
- One-command startup:
make up(Docker Compose). - Swagger/OpenAPI available for API.
- README includes architecture diagram, quickstart, perf results screenshot, and design tradeoffs.
- Minimal Locust (or k6) scenario for write & read loads with a report.
(High-level ASCII diagram omitted here for brevity — see diagrams/architecture.png in final repo.)
(See detailed schema above.)
POST /reserve, GET /slots/{id}, etc.
(Full folder tree with python/go versions.)
Describes Actor, Producer, Consumer logic, Redis caching, SWR behavior, etc.
Prometheus, Grafana, OpenTelemetry setup.
Docker Compose, Makefile commands, etc.
Unit, Integration, Locust/k6 tests.
DLQ, Replay, Outbox, WS Push, Sharding.
Lint, CI/CD, metrics, OpenAPI, etc.
KAFKA=localhost:9092
REDIS=redis://localhost:6379
PG=postgres://dev:dev@localhost:5432/app
GROUP=iron-worker
TOPIC=reservations
Bootstrap → Python → Go → Metrics → Load Test → README polish.
01-four-pillars.md
02-from-locks-to-actors.md
03-linux-vs-zephyr-devicetree.md
04-1b-interactions-architecture.md
We don’t fight locks — we redesign contention.
Parallel reads, serialized writes, read/write separation, async state.
Locks are a human reflex to inconsistency; asynchrony is computation’s natural posture. — Harrison
Deliverables:
- Working Python & Go services under
python/andgo/with identical behavior. - Docker Compose one-click run.
- Metrics exposed; basic dashboard JSON (optional).
- Benchmarks + README screenshots.
- Blogs & diagrams included.
If a tradeoff is needed due to time, prioritize correctness by design, observability, and benchmarks over extra features.