Event Stream
StorageDurable message streaming platform for pub/sub, event sourcing, and asynchronous communication between services with ordering guarantees.
Overview
An Event Stream (also known as a message queue or event bus) is a durable messaging platform that enables asynchronous, decoupled communication between services. Producers publish events (messages) to topics, and consumers subscribe to those topics to receive events. Unlike direct service-to-service calls, event streams decouple producers from consumers in time (the consumer does not need to be available when the event is published) and space (the producer does not need to know who consumes the event). This decoupling is the foundation of event-driven architectures and is essential for building scalable, resilient microservices.
Pub/sub (publish-subscribe) is the primary communication pattern. A producer publishes an order_placed event, and multiple independent consumers process it: an inventory service reserves stock, a notification service emails the customer, an analytics service records the conversion, and a fraud detection service checks for suspicious patterns. Each consumer reads the event independently at its own pace. Adding a new consumer requires zero changes to the producer — this is the power of event-driven loose coupling.
Partitioning enables horizontal scaling of both throughput and consumption. A topic is divided into partitions, and each partition maintains strict ordering of events. Events are assigned to partitions based on a partition key (e.g., order_id, user_id), ensuring all events for the same entity are processed in order. Consumers in a consumer group each handle a subset of partitions, providing parallel processing. Scaling throughput means adding partitions and consumers. Vetora models partition distribution and shows how partition count affects throughput and ordering guarantees.
Consumer groups enable multiple independent processing pipelines on the same event stream. Each consumer group maintains its own offset (position) in the stream, reading events independently. The inventory group and the analytics group each process all events, but each group can have multiple members that share the partition workload. If a consumer in a group fails, its partitions are automatically redistributed to healthy members (consumer rebalancing). Vetora models consumer group behavior, including rebalancing delays and their impact on processing latency.
Event replay is a unique advantage of durable event streams like Kafka. Unlike traditional message queues that delete messages after delivery, event streams retain messages for a configurable period (days, weeks, or indefinitely). Consumers can reset their offset to replay historical events — invaluable for rebuilding derived state after a bug fix, onboarding a new service that needs to catch up on historical events, or debugging production issues by replaying the exact sequence of events that caused a failure.
When to Use
Recommended
- +Asynchronous service-to-service communication in microservices — decoupling producers from consumers
- +Event sourcing architectures where the event log is the source of truth for application state
- +Fan-out workloads where a single event triggers processing by multiple independent consumers
- +Buffering between producers and consumers with different throughput capacities — the stream absorbs traffic spikes
- +Data integration pipelines moving events between services, databases, caches, and analytics platforms
Not Recommended
- -Synchronous request-response flows where the caller needs an immediate result — use direct service calls
- -Simple point-to-point messaging with a single consumer — a basic task queue (SQS, RabbitMQ) may be simpler
- -Low-latency requirements below 1ms — event streams add serialization and network overhead
Key Parameters in Vetora
Real-World Examples
Apache Kafka
Distributed event streaming platform handling trillions of events per day at organizations like LinkedIn, Uber, and Netflix. Provides durable, partitioned, replicated event logs with consumer groups and exactly-once semantics.
Apache Pulsar
Cloud-native messaging and streaming platform with multi-tenancy, geo-replication, and tiered storage. Separates serving (brokers) from storage (BookKeeper) for independent scaling.
AWS SQS / SNS
SQS provides managed message queues (standard and FIFO). SNS provides pub/sub topic-based messaging. Combined, they enable fan-out patterns with SQS queues subscribing to SNS topics for reliable, decoupled processing.
Frequently Asked Questions
What is an event stream in system design?
An event stream is a durable messaging platform where producers publish events to topics and consumers subscribe to receive them asynchronously. Unlike direct API calls, event streams decouple producers from consumers — the producer does not need to know who consumes events, and consumers do not need to be available when events are published. Event streams like Apache Kafka retain events durably, enabling replay and event sourcing. They are the backbone of event-driven microservices architectures.
What is the difference between a message queue and an event stream?
Traditional message queues (SQS, RabbitMQ) delete messages after a consumer acknowledges them — each message is processed once by one consumer. Event streams (Kafka, Pulsar) retain messages for a configurable period, allowing multiple consumer groups to read independently and enabling event replay. Message queues focus on task distribution; event streams focus on event publishing and consumption. Event streams provide ordering guarantees within partitions and support higher throughput through partitioned parallelism.
How does Kafka partitioning work?
Kafka topics are divided into partitions — ordered, immutable sequences of events. Events are assigned to partitions based on a partition key (hash of user_id, order_id, etc.), ensuring all events with the same key go to the same partition and are processed in order. Within a consumer group, each partition is consumed by exactly one consumer. Increasing partitions increases parallelism and throughput. The number of partitions sets the upper bound on consumer parallelism — you cannot have more active consumers than partitions in a group.
What are consumer groups in event streaming?
A consumer group is a set of consumers that collectively process a topic's events. Each partition is assigned to exactly one consumer within the group, providing parallel processing. Multiple consumer groups can read the same topic independently — an analytics group and a notification group each process all events. If a consumer fails, its partitions are reassigned to remaining group members (rebalancing). Each group tracks its own read position (offset) in the stream, enabling independent processing rates and replay capabilities.
What is event replay and why is it valuable?
Event replay is the ability to re-read historical events from an event stream by resetting a consumer's offset (read position) to an earlier point. It is valuable for several scenarios: rebuilding a corrupted database by replaying all events that constructed it, onboarding a new service that needs to process historical events to build its initial state, debugging production issues by replaying the exact event sequence that caused a failure, and testing new processing logic against real historical data. This capability is unique to durable event streams and is unavailable in traditional message queues that delete messages after processing.
Related Components
Background processor that handles asynchronous tasks from job queues, supporting retries, dead lette...
Real-time event processing engine that handles continuous data streams with windowing, state managem...
Application server or microservice that processes requests, runs business logic, and communicates wi...
Persistent data store supporting SQL or NoSQL models with ACID transactions, replication, sharding, ...
Try Event Stream in the Simulator
Build architectures with Event Stream and 13 other component types. Run discrete event simulations and get AI-powered feedback.
Open Playground