Skip to content

[SPIKE] High-Throughput Trade-Matching Engine via Redis Streams & WebSocketsΒ #344

Description

@jotel-dev

[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:

  1. Stream Producer: Prototype publishing cash requests to Redis Stream stream:cash_requests.
  2. 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.
  3. Benchmarking: Benchmark throughput (operations/sec) under simulated loads of 1,000 concurrent requests.
  4. Deliverables:
    • Architectural document: docs/spikes/redis-matching-engine.md.
    • Runnable benchmark script: examples/matching_engine_benchmark.ts.

πŸ€– AI-Assisted Implementation Guide (1-Hour Workflow)

  1. Step 1 (15m): Ask AI to write a TypeScript Redis Stream producer and consumer group worker module using ioredis.
  2. Step 2 (25m): Have AI write a stress-test generator spawning 1,000 concurrent cash request payloads and measuring latency distribution (p50, p95, p99).
  3. Step 3 (20m): Instruct AI to compile latency benchmarks and architectural trade-offs into docs/spikes/redis-matching-engine.md.

βœ… Acceptance Criteria

  • Published benchmark report in docs/spikes/redis-matching-engine.md.
  • Runnable benchmark script outputting throughput metrics.
  • Demonstrated p95 processing latency < 15ms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions