Home
ArenaGraphSignalTopics

/ The Arena

Prove your engineering skills.

GLOBAL+50 XP

Build an Idempotent Payment Engine with Distributed Locks

Landmark Capstone: Distributed Idempotency Engine

In distributed systems, network partitions and client retries can result in catastrophic duplicate transactions. Your objective is to build a production-grade Idempotency Middleware backed by Redis.

Requirements:

  1. Cache Hit: If a request with idempotencyKey has already been executed, immediately return the cached status and payload with isIdempotentHit: true.
  2. Concurrent Lock Acquisition: Acquire an atomic distributed lock (SET NX EX). If another worker is actively executing the same key, return HTTP 409 Conflict and { error: 'CONCURRENT_REQUEST_IN_PROGRESS' }.
  3. Payload Fingerprint Validation: If a subsequent request reuses an existing idempotencyKey with a mismatched HTTP method, path, or body payload, return HTTP 422 Unprocessable Entity and { error: 'IDEMPOTENCY_KEY_PAYLOAD_MISMATCH' }.
  4. Atomic Commitment & Safe Unlock: Commit the response to Redis with a 24-hour TTL and release the lock to guarantee safe concurrent execution.

Join The Arena

Create an account to submit your implementation, test against our containerized CI suite, and climb the global leaderboard.

Create Account

ALREADY HAVE AN ACCOUNT? LOG IN