[SPIKE] Architecture & Benchmark Spike: Low-Latency Trade-Matching Engine via Redis Streams
π·οΈ Metadata
- Type: Spike / Architecture & Benchmarking
- Difficulty: Hard
- Estimated Time (with AI aid): ~60 minutes
- Primary Stack: TypeScript, Node.js, Redis Streams, WebSockets
π Background & Context
When buyers create cash requests, liquidity providers in the same geographic region compete to fulfill them. Relying solely on database polling introduces latency. We need to evaluate an in-memory, event-driven order matching architecture using Redis Streams.
π― Problem Statement & Scope
Evaluate and prototype an order-matching pipeline for cash requests:
- Stream Producer: Prototype publishing cash requests to Redis Stream
stream:cash_requests.
- Consumer Group Matcher: Implement a worker node using Redis Consumer Groups to match cash requests to registered providers within a 5km radius under 10ms processing time.
- Benchmarking: Benchmark throughput (operations/sec) under simulated loads of 1,000 concurrent requests.
- Deliverables:
- Architectural document:
docs/spikes/redis-matching-engine.md.
- Runnable benchmark script:
examples/matching_engine_benchmark.ts.
π€ AI-Assisted Implementation Guide (1-Hour Workflow)
- Step 1 (15m): Ask AI to write a TypeScript Redis Stream producer and consumer group worker module using
ioredis.
- Step 2 (25m): Have AI write a stress-test generator spawning 1,000 concurrent cash request payloads and measuring latency distribution (p50, p95, p99).
- Step 3 (20m): Instruct AI to compile latency benchmarks and architectural trade-offs into
docs/spikes/redis-matching-engine.md.
β
Acceptance Criteria
[SPIKE] Architecture & Benchmark Spike: Low-Latency Trade-Matching Engine via Redis Streams
π·οΈ Metadata
π Background & Context
When buyers create cash requests, liquidity providers in the same geographic region compete to fulfill them. Relying solely on database polling introduces latency. We need to evaluate an in-memory, event-driven order matching architecture using Redis Streams.
π― Problem Statement & Scope
Evaluate and prototype an order-matching pipeline for cash requests:
stream:cash_requests.docs/spikes/redis-matching-engine.md.examples/matching_engine_benchmark.ts.π€ AI-Assisted Implementation Guide (1-Hour Workflow)
ioredis.docs/spikes/redis-matching-engine.md.β Acceptance Criteria
docs/spikes/redis-matching-engine.md.