Design a Multi-Channel Message Queue

Read the full interview experience this question came from →

Quick Overview

This question evaluates understanding of data modeling for multi-tag messages, set-based subscription semantics, scalable system design, and algorithmic complexity for operations such as enqueue, dequeue, subscribe/unsubscribe, and intersection queries.

Design a Multi-Channel Message Queue

Company: Cerebras

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Technical Screen

Design a custom message-queue data structure that supports multiple communication channels per message and channel-based subscriptions for consumers. Extend the design to add additional channels; determine how many channels are needed to cover a given set of producer–consumer communication patterns. Describe how you would represent channel identifiers and use union/intersection operations to detect shared communication channels efficiently. Analyze the time and space complexity of enqueue, dequeue, subscribe/unsubscribe, and channel-query operations.

Overview: This question evaluates understanding of data modeling for multi-tag messages, set-based subscription semantics, scalable system design, and algorithmic complexity for operations such as enqueue, dequeue, subscribe/unsubscribe, and intersection queries.

Read the full Cerebras Software Engineer interview experience this question came from

|Home/System Design/Cerebras
Cerebras logo
Cerebras
Sep 6, 2025
hardSoftware EngineerTechnical ScreenSystem Design
13
0

Design a Message Queue with Multi-Channel Messages and Channel-Based Subscriptions

Context

You are asked to design a message-queue data structure where:

  • Each message may belong to multiple communication channels (tags).
  • Consumers subscribe to channels and should receive messages if they share at least one channel with the message.
  • The system must support adding new channels dynamically, efficient detection of shared channels via union/intersection, and analysis of operation complexities.
  • Additionally, given a set of desired producer–consumer communication pairs, determine how many channels are needed and how to assign them to cover these patterns.

Requirements

  1. Data model where messages can have multiple channels and consumers subscribe to channels.
  2. Efficient operations:
    • Enqueue message
    • Dequeue/consume message
    • Subscribe/Unsubscribe consumer to channels
    • Query shared channels (e.g., does message M intersect consumer C’s subscriptions?)
  3. Representation of channel identifiers enabling fast union/intersection.
  4. Support adding channels at runtime.
  5. Analyze time and space complexity for all operations.
  6. Given a set of producer–consumer communication patterns, determine the minimum (or a good) number of channels required and how to assign them.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...