System Design Interview Volume 2 (3)
분산 메세지 큐
- Advantages
- 결합도 완화 (decoupling): Component 사이의 강한 결합이 사라지므로 각각 독립적 갱신 가능
- 규모 확장성 개선: Message queue에 data를 생산하는 생산자 (producer)와 queue에서 message를 소비하는 소비자 (consumer) system 규모를 traffic 부하에 맞게 독립적으로 scale out 가능
- 가용성 개선: System의 특정 component에 장애가 발생해도 다른 component는 queue와 계속 상호작용 가능
- 성능 개선: 손쉬운 비동기 통신 가능 ($\because$ producer는 응답을 기다리지 않고 message 생산, consumer는 읽을 message가 있을 때 소비)
- Message queue vs. Event streaming platform
- Apache Kafka와 Pulsar는 message queue가 아닌 event streaming platform
- RocketMQ, ActiveMQ, RabbitMQ, ZeroMQ와 같은 message queue와 비교하여 지원 기능이 점점 비슷해져 차이가 희미해짐
Feature | Message Queue (e.g., RabbitMQ, ActiveMQ) | Event Streaming Platform (e.g., Kafka, Pulsar) |
---|---|---|
Primary Use Case | Decoupling producers and consumers | Real-time data streaming and processing |
Message Retention | Short-term, until consumed | Long-term, configurable retention |
Message Ordering | FIFO (First In, First Out) | Partition-based ordering |
Scalability | Limited, vertical scaling | High, horizontal scaling |
Throughput | Moderate | High |
Latency | Low | Low to moderate |
Fault Tolerance | Basic | Advanced, with replication |
Consumer Model | Push-based | Pull-based |
Use Case Examples | Task queues, notification systems | Log aggregation, real-time analytics |