Message Queues and Event Streaming: Kafka, RabbitMQ and Service Bus Interview Questions
261 multiple-choice tech interview questions on Message Queues and Event Streaming: Kafka, RabbitMQ and Service Bus: queues vs topics, delivery guarantees, idempotent consumers, Kafka partitions and consumer groups, dead-lettering. Written for technical phone screens and interview prep, organized by subtopic, with a short explanation for every answer. Learn the 244 key terms with the flashcards first, then test yourself.
Take the practice test · Flashcards · All study tools
What it covers
- 9.1 Messaging fundamentals and delivery semantics
- 9.2 Reliability, retries and dead-lettering
- 9.3 Ordering, concurrency and scaling consumers
- 9.4 Kafka architecture and producers
- 9.5 Kafka consumers, offsets and operations
- 9.6 RabbitMQ and AMQP
- 9.7 Azure messaging: Service Bus, Event Hubs and Event Grid
- 9.8 AWS, Google Cloud and other brokers
- 9.9 Message design, security and observability
Key terms
9.1 Messaging fundamentals and delivery semantics
- Queue
- Point-to-point channel where each message is processed by one consumer
- Topic
- Publish-subscribe channel delivering each message to every subscription
- Dead-letter queue
- Holding area for messages that cannot be processed successfully
- At-least-once delivery
- Messages are never lost but may be delivered more than once
- Idempotent consumer
- A consumer for which processing a message twice has the same effect as once
- Peek-lock
- Receive mode where a message is locked, then completed or abandoned
- Topic fan-out
- Subscription per service
- Message broker
- Stores and routes
- Push vs pull
- Broker sends vs consumer fetches
- Pull consumers
- Own pace, rewind
- Durable queue
- Survives restarts
- Acknowledgment
- Message handled
- Message TTL
- Expiry
- Async tradeoff
- Latency and complexity
- Document message
- Data only
- Message headers
- Metadata
- Scheduled message
- Delayed delivery
- Priority queue
- Higher first
- ZeroMQ
- Brokerless library
- MQTT
- IoT pub/sub
- MQTT QoS
- 0, 1, 2
- JMS
- Java messaging API
- Producer batching
- Throughput vs latency
- Broker replication
- Survive node loss
- Enterprise Integration Patterns
- Messaging catalog
- Content-based router
- Route by content
- Durable subscription
- Keeps messages offline
- Aggregator
- Combine related messages
- Wire tap
- Copy for inspection
- Store and forward
- Hold then deliver
9.2 Reliability, retries and dead-lettering
- Max delivery count
- Attempts before DLQ
- Delivery count of 1
- No retries
- Transient vs permanent
- Retry or dead-letter
- DLQ alerting
- Don't forget failures
- Redrive
- Back to source queue
- Dead-letter metadata
- Reason and count
- Retry queues
- Growing delays
- Partition blocking
- In-place retries stall
- Inbox pattern
- Processed IDs
- Natural idempotency
- Set, not increment
- Ack after commit
- Redelivery over loss
- Producer duplicates
- Lost acks
- Consumer pausing
- Dependency down
- Dead-letter topic
- Kafka failures
- Outbox relay
- Publish unsent rows
- Expiry loss
- TTL during outage
- Failure testing
- Inject errors
- DLQ replay risk
- Stale or reordered
- Handler timeout
- No hung workers
- Per-type queues
- Isolation
- Failure logging
- ID and count
- Publish validation
- Stop bad data early
- Side-effect duplicates
- Repeat emails or charges
- Missing reference
- Delayed retry
- Per-queue DLQ
- Tied to source
- Abandon / nack
- Immediate redelivery
9.3 Ordering, concurrency and scaling consumers
- In-flight cap
- Bounded concurrency
- Total ordering
- One partition bottleneck
- FIFO cost
- Lower throughput
- Prefetch
- Unacked messages held
- Prefetch hoarding
- Uneven work
- KEDA
- Event-driven autoscaling
- Consumer concurrency
- Parallel handling
- Key-affine workers
- Per-key order
- Head-of-line blocking
- Slow message delays others
- Sequence numbers
- Detect reordering
- Single active consumer
- Standby consumers
- Handler sizing
- Rate × duration
- Slow consumer
- Memory pressure
- Key skew
- Overloaded partition
- Self-throttling
- Respect API limits
- Fan-out load
- Copy per subscription
- Scale-to-zero delay
- Startup wait
- Long jobs
- State outside the message
- Job splitting
- Parallel small messages
- Tenant fairness
- Separate queues
- Retries vs order
- Later messages first
- Urgent queue
- Dedicated capacity
- Backlog drain
- Spare capacity
- Downstream limits
- Database connections
- Batched acks
- Fewer round trips
- Queue wait time
- Message age
- Broker-managed locks
- No consumer coordination
- Ordered group limit
- One at a time
9.4 Kafka architecture and producers
- Partition
- An ordered, append-only log within a Kafka topic; the unit of parallelism
- Consumer group
- Set of consumers that share a topic's partitions, each partition read by one member
- Offset
- A record's position in a Kafka partition
- Partition leader
- Serves reads and writes
- ISR
- Caught-up replicas
- acks=all
- Wait for ISR
- min.insync.replicas
- Minimum copies
- Replication factor 3
- Survive one failure
- Unclean leader election
- Possible data loss
- Idempotent producer
- No retry duplicates
- Kafka transactions
- Atomic writes and offsets
- read_committed
- Hide aborted records
- linger.ms
- Batch wait
- Producer compression
- zstd, lz4
- Sticky partitioner
- Keyless batching
- Adding partitions
- Key remapping
- Partition overhead
- Metadata and files
- Retention
- Time or size
- Tiered storage
- Old segments to object storage
- Append-only log
- No in-place updates
- Tombstone
- Null value deletes key
- Kafka speed
- Sequential I/O, zero-copy
- KRaft controller
- Metadata quorum
- Kafka Connect
- Source and sink connectors
- Kafka Streams
- Stream processing library
- Kafka record
- Key, value, headers
- Idempotent ordering
- Up to 5 in flight
- Rack awareness
- Replicas across zones
9.5 Kafka consumers, offsets and operations
- Independent groups
- Each gets all records
- Auto-commit risk
- Commit before processing
- auto.offset.reset
- Where new groups start
- Consumer lag
- Offset gap
- Lag trend
- Growing means behind
- Offset reset by time
- Reprocess history
- consumer-groups CLI
- Offsets and lag
- max.poll.interval.ms
- Stuck consumer
- Heartbeat
- Liveness
- Cooperative rebalancing
- Incremental moves
- KIP-848
- Broker-driven assignment
- Static membership
- Quick restarts
- Share groups
- Queues for Kafka
- __consumer_offsets
- Offset storage
- Consumer thread safety
- One per thread
- Under-replicated partitions
- Followers behind
- Rolling upgrade
- One broker at a time
- Cruise Control
- Partition rebalancing
- MirrorMaker 2
- Cross-cluster replication
- Client quotas
- Rate caps
- Offsets in database
- Exactly-once sink
- Rebalance storm
- Repeated pauses
- Offset retention
- 7-day default
- Fetch tuning
- Throughput vs latency
- Single-partition lag
- Hot key or stuck record
9.6 RabbitMQ and AMQP
- Direct exchange
- Exact key match
- Topic wildcard *
- One word
- Topic wildcard #
- Zero or more words
- Fanout exchange
- Broadcast to queues
- Headers exchange
- Route on headers
- Default exchange
- Key names the queue
- Quorum queue
- Raft-replicated queue
- Mirrored queues removed
- RabbitMQ 4.0
- RabbitMQ streams
- Replayable log
- Publisher confirms
- Broker acks to publisher
- Unroutable message
- Dropped by default
- Alternate exchange
- Catches unrouted
- Dead-letter exchange
- DLX
- Requeue loop
- Immediate refail
- Delivery limit
- Max redeliveries
- Memory watermark
- Blocks publishers
- Virtual host
- Namespace
- Channels
- Multiplexed connection
- AMQP 0-9-1
- Native protocol
- Exclusive queue
- One connection
- autoAck
- At-most-once
- Management plugin
- Web UI and API
- Shovel and Federation
- Cross-broker transfer
- Khepri
- Raft metadata store
- reject-publish
- Full queue rejects
- Erlang
- RabbitMQ's language
- Consistent hash exchange
- Hash key to queue
- Delayed messages
- Plugin or TTL + DLX
9.7 Azure messaging: Service Bus, Event Hubs and Event Grid
- Exchange
- RabbitMQ component that routes messages to queues through bindings
- Receive-and-delete
- Removed on receipt
- Lock renewal
- Extend processing time
- Subscription filters
- Choose messages
- Correlation filter
- Cheap property match
- Deferral
- Fetch later by sequence number
- Service Bus transactions
- Complete and send atomically
- Premium tier
- Dedicated capacity
- 100 MB messages
- Premium limit
- Auto-forwarding
- Chain entities
- $deadletterqueue
- Dead-letter subqueue
- Event Hubs consumer group
- Own read positions
- Event Hubs Capture
- Archive to storage
- Checkpointing
- Saved offsets
- Throughput units
- 1 MB/s in
- Event Hubs retention
- 7 or 90 days
- Event Grid retries
- 24 hours then DLQ
- Event Grid namespaces
- Pull and MQTT
- Telemetry choice
- Event Hubs
- Storage queues
- Simple, huge backlogs
- 64 KB
- Storage queue message limit
- Entra auth
- Managed identity
- Geo-DR
- Metadata only
- Session state
- Per-session storage
9.8 AWS, Google Cloud and other brokers
- SQS standard vs FIFO
- Throughput vs order
- MessageGroupId
- Ordered group
- FIFO deduplication
- 5-minute window
- Long polling
- Wait up to 20 s
- SQS retention
- 1 min to 14 days
- SQS message size
- 1 MiB
- Redrive policy
- maxReceiveCount
- Delay queue
- Up to 15 minutes
- SNS to SQS fan-out
- Topic to queues
- SNS filter policy
- Attribute matching
- SNS FIFO
- Ordered fan-out
- Kinesis shard
- 1 MB/s in
- Kinesis on-demand
- Auto capacity
- Kinesis vs SQS
- Stream vs queue
- Enhanced fan-out
- Dedicated throughput
- Amazon MSK
- Managed Kafka
- Amazon MQ
- Managed ActiveMQ/RabbitMQ
- EventBridge Pipes
- Source to target
- EventBridge Scheduler
- Scheduled invocations
- Ordering keys
- Per-key order
- Ack deadline
- Redelivery timer
- Pub/Sub exactly-once
- No redelivery after ack
- Seek
- Replay by snapshot
- JetStream
- NATS persistence
- Pulsar
- BookKeeper storage
- Redpanda
- C++ Kafka API
9.9 Message design, security and observability
- Message envelope
- Metadata wrapper
- Message ID
- Dedup and tracing
- Causation ID
- Direct parent
- Occurred vs published
- Two timestamps
- Small messages
- Cheaper, faster
- Tolerant reader
- Ignore unknown fields
- Type and version headers
- Route before parsing
- Business IDs
- Stable across systems
- Personal data
- Minimize in payloads
- Broker TLS
- Encrypted connections
- Kafka ACLs
- Topic permissions
- SASL
- SCRAM, OAUTHBEARER
- Per-service credentials
- Least privilege
- Message signatures
- Verify sender
- Queue metrics
- Depth, age, errors
- End-to-end latency
- Publish to done
- Heartbeat message
- Pipeline check
- Producer metadata
- Trace bad messages
- Recorded payloads
- Realistic tests
- Payload compression
- Smaller messages
- Topic naming
- Domain, event, version
- Retention policy
- Cost vs replay
- Private endpoints
- No public access
- Admin audit trail
- Trace changes
- Topic creation control
- Avoid sprawl
- Valid-until
- Skip stale commands
- Unknown types
- Log and skip
- Enum evolution
- Unknown values
- Topic ownership
- Accountable team
Sample practice questions
What is the key difference between a queue and a publish-subscribe topic?
- A queue keeps messages forever, while a topic deletes them as soon as they arrive
- Topics only work over HTTP, while queues only work over raw TCP connections
- Queues support message ordering, while topics never preserve any order at all
- A queue gives each message to one consumer; a topic copies it to every subscription
Answer: D. A queue gives each message to one consumer; a topic copies it to every subscription Use queues for work distribution (competing consumers) and topics for broadcasting events.
What is a dead-letter queue (DLQ)?
- A queue that holds the records of users who deleted their accounts
- A side queue for messages that can't be processed or have expired
- A queue configured to silently drop every message it receives
- The name for the main queue after the broker has crashed
Answer: B. A side queue for messages that can't be processed or have expired DLQs keep "poison messages" from blocking the queue and preserve them for inspection and replay.
What is the competing consumers pattern?
- Consumers place bids to decide which of them processes each message
- Several instances read one queue, processing messages in parallel
- Two separate queues compete with each other to receive the same message
- Only the single fastest consumer instance is allowed to keep running
Answer: B. Several instances read one queue, processing messages in parallel Each message goes to just one of the consumers, so adding consumers increases throughput.
How does Apache Kafka differ from a traditional queue like RabbitMQ?
- Kafka deletes each message as soon as any single consumer has read it
- Kafka supports only one consumer per topic, so messages can't fan out
- Kafka is a retained, append-only log that many consumers can read and replay
- Kafka keeps messages only in memory, so they're lost when a broker restarts
Answer: C. Kafka is a retained, append-only log that many consumers can read and replay Kafka consumers track their own offsets; RabbitMQ traditionally removes messages once acknowledged.
A Kafka topic has 6 partitions and a consumer group has 8 consumers. What happens?
- All 8 consumers share every partition equally
- Kafka adds 2 new partitions automatically
- 6 consumers get a partition each; 2 sit idle
- The consumer group fails to start at all
Answer: C. 6 consumers get a partition each; 2 sit idle Within a consumer group, partitions are the ceiling on parallelism.
In RabbitMQ, what routes messages from producers to queues?
- Partitions, assigned by message key
- Exchanges, with bindings to queues
- Consumer offsets, stored per group
- Shards, chosen by a hash of the body
Answer: B. Exchanges, with bindings to queues Producers publish to an exchange, which routes copies to bound queues based on routing keys and exchange type.
In Azure Service Bus peek-lock mode, what happens if a consumer crashes before completing a message?
- The lock expires and the message is redelivered, with its delivery count raised
- The message is deleted permanently, since it was already received once
- The message is moved straight to the dead-letter queue on the first failure
- The whole queue stays locked until an administrator manually releases it
Answer: A. The lock expires and the message is redelivered, with its delivery count raised After MaxDeliveryCount (10 by default) failed attempts, Service Bus dead-letters the message.
What is Amazon SQS?
- A managed message queue with standard and FIFO queues
- A managed Kafka cluster for streaming event data
- A managed relational database for transactions
- A managed service for sending marketing emails
Answer: A. A managed message queue with standard and FIFO queues SNS handles pub/sub fan-out and is often combined with SQS queues. Amazon MSK is managed Kafka.
What is a message envelope?
- A batch of messages sent together in one network call
- A wrapper with metadata like ID, type and version around the payload
- The broker's record of which consumer got each message
- An encrypted container that only the broker can open
Answer: B. A wrapper with metadata like ID, type and version around the payload Payload and metadata stay separate.
What is backpressure in a messaging system?
- Compressing messages before sending them to save network bandwidth
- Retrying failed messages faster so the queue drains more quickly
- Sending messages backwards through the queue to their producers
- Slow consumers making producers slow down so buffers don't overflow
Answer: D. Slow consumers making producers slow down so buffers don't overflow Without backpressure, queues grow without bound or brokers start rejecting messages.
More Storage and Data
- Relational Database Design and Normalization
- SQL Queries, Joins and Window Functions
- Indexing and Query Optimization
- Transactions, ACID and Isolation Levels
- NoSQL Databases: Document, Key-Value, Wide-Column and Graph
- Caching: Redis, CDNs and Cache Invalidation
- ORMs: Entity Framework Core and Hibernate
- Data Warehousing and ETL
- Blob and Object Storage
- Backups, Replication and Disaster Recovery