Prompt
I'm building a microservices system and need pub/sub for service events, what are the best options?
Latest observation
For microservices pub/sub, the “best” option depends mostly on throughput, delivery guarantees, operational burden, and whether you want a broker or a streaming platform. Here are the strongest choices:
Top options
1) Kafka
Best for: high throughput, event streaming, replay, durable event history
Pros
- Very high throughput and scalable
- Strong ecosystem
- Consumer groups, partitions, replayable logs
- Great for event-driven architectures and audit/history use cases
Cons
- Heavier ops than simpler brokers
- Semantics can be more complex than “classic pub/sub”
- Not ideal if you only need simple low-latency message passing
Use if: you need durable events, multiple consumers, replay, analytics integration.
2) RabbitMQ
Best for: traditional messaging, flexible routing, reliable delivery
Pros
- Easier to understand for many teams
- Strong routing patterns (topics, fanout, direct, headers)
- Good reliability and mature tooling
- Great for command/message-based microservices
Cons
- Usually not as suitable as Kafka for very high-volume streaming
- Replay/event-log style use cases are weaker
Use if: you want a classic message broker for service-to-service messaging.
3) NATS / NATS JetStream
Best for: lightweight, low-latency pub/sub
Pros
- Very fast and simple
- Low operational overhead
- JetStream adds persistence, replay, and durable consumers
- Good fit for microservices and cloud-native systems
Cons
- Smaller ecosystem than Kafka
- Less common for data-platform-style streaming
Use if: you want simple, fast pub/sub with optional persistence.
4) AWS SNS + SQS
Best for: managed cloud-native pub/sub on AWS
Pros
- Fully managed, low ops
- SNS for pub/sub fanout, SQS for durable queues
- Easy to integrate with AWS services
Cons
- AWS-specific
- More fragmented model than a single broker
- Cross-service event replay/stream processing less natural than Kafka
Use if: you’re already on AWS and want managed infrastructure.
5) Google Pub/Sub
Best for: managed pub/sub on GCP
Pros
- Fully managed, scalable
- Good for event-driven microservices
- Minimal ops burden
Cons
- GCP-specific
- Less control than self-managed brokers
Use if: you’re on GCP and want managed messaging.
6) Azure Service Bus / Event Hubs
Best for: Azure-managed messaging and streaming
Pros
- Managed, integrates well with Azure
- Service Bus for brokered messaging
- Event Hubs for streaming/event ingestion
Cons
- Azure-specific
- Two products with different strengths can complicate decisions
Use if: you’re on Azure.
Quick recommendation by scenario
- Need replayable event streams, analytics, event sourcing: Kafka
- Need classic pub/sub with routing and reliability: RabbitMQ
- Need lightweight, fast, simple microservice messaging: NATS JetStream
- Need managed cloud service and minimal ops: SNS+SQS / Google Pub/Sub / Azure Service Bus
- Need stream ingestion at scale: Kafka or Event Hubs
Practical guidance
For microservices, a common rule of thumb is:
- Use Kafka if “events are a product” and you expect multiple consumers, replay, and scale.
- Use RabbitMQ if you need work queues, routing, and straightforward service messaging.
- Use NATS if you want simplicity and speed.
- Use managed cloud pub/sub if you prioritize operations over portability.
Important design notes
No matter what you choose:
- Make messages idempotent (assume duplicates can happen)
- Include event versioning
- Plan for dead-letter queues
- Define delivery semantics clearly: at-most-once / at-least-once / exactly-once
- Avoid tight coupling between producers and consumers
- Use a schema strategy like JSON Schema, Avro, or Protobuf
If you want a direct default choice
- General-purpose default: Kafka
- Simpler operationally for microservices: NATS JetStream
- Classic enterprise messaging: RabbitMQ
If you tell me your stack and constraints (cloud provider, expected message volume, need for replay, team size, latency requirements), I can recommend a specific option and architecture.