Preparing your design workspace

Loading the problem and your latest saved attempt…

Multi-Channel Message Routing Queue

Design a queue in which messages carry multiple channel labels and consumers receive work when their subscriptions intersect those labels.

Problem statement

For this exercise, assume producers enqueue durable messages labeled with one or more dynamically created channels. A consumer owns a subscription set and is eligible when that set intersects a message's channel set.

Within one producer stream, an eligible consumer group must observe messages in order; delivery is at least once with acknowledgement, lease expiry, retry, and dead-letter handling. Callers also need bounded union and intersection queries over message and subscription channel sets.

Administrators need an offline planning operation that proposes a compact channel assignment for a desired producer-to-consumer communication matrix.

Design the data model, queue operations, indexes, partitioning, concurrency control, and channel-planning workflow, and analyze the time and space complexity of enqueue, claim/dequeue, subscribe/unsubscribe, and channel-set queries.

Exclude exactly-once business processing and arbitrary boolean subscription expressions.

What to build

  1. A producer can idempotently enqueue a durable message with one or more active channel IDs.
  2. Consumers can change channel subscriptions and claim, acknowledge, or release eligible messages under at-least-once delivery.
  3. A caller can query the bounded union or intersection of a message's channel set and a versioned consumer subscription, including whether the pair is eligible.
  4. An administrator can submit a producer-consumer communication matrix and receive a versioned feasible channel assignment with coverage metrics.

At scale

  • Assume 100,000 channels, 10 million consumers, one billion retained messages, and 250,000 enqueues per second at peak.
  • A message has at most 32 channels and a consumer subscribes to at most 256 channels.
  • Target p95 enqueue below 100 ms and claim below 250 ms when a consumer has eligible work.
  • Subscription changes take effect within five seconds and must not strand messages or silently violate the declared ordering scope.