Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

Event Streaming Fundamentals

Core concepts underlying Apache Kafka and modern event-driven architectures.


Event streaming is a paradigm for capturing, storing, and processing continuous flows of data as they occur. Unlike traditional request-response architectures where applications query databases on demand, event streaming systems treat data as a continuous stream of immutable events that applications can observe, process, and react to in real time.

Apache Kafka implements event streaming through a distributed commit log—an append-only data structure that provides durable, ordered storage of events with high throughput and low latency.


Three fundamental paradigms exist for asynchronous communication between systems: point-to-point messaging, publish-subscribe, and event logs. Understanding these paradigms clarifies where Kafka fits and why it was designed the way it was.

Point-to-point, publish-subscribe, and event log messagingPoint-to-point, publish-subscribe, and event log messagingPoint-to-Point (Queue)Publish-SubscribeEvent Log (Kafka)ProducerQueueConsumer AConsumer BPublisherTopicSubscriber ASubscriber BProducerLogConsumer A(offset: 5)Consumer B(offset: 3)sendreceive (removed)competingpublishdeliver (copy)deliver (copy)appendreadread

In point-to-point messaging, producers send messages to a queue, and exactly one consumer receives each message. Once a consumer acknowledges a message, it is removed from the queue.

CharacteristicBehavior
Message consumptionEach message delivered to exactly one consumer
Message lifetimeRemoved after acknowledgment
Consumer coordinationCompeting consumers—load balanced across instances
Replay capabilityNot supported—messages are deleted

Point-to-point queues excel at work distribution: tasks that must be processed exactly once by one worker. Traditional message brokers like RabbitMQ, IBM MQ, and ActiveMQ implement this pattern.

In publish-subscribe systems, publishers send messages to topics, and all subscribers to that topic receive a copy of each message. Messages are typically delivered in real time and may or may not be retained.

CharacteristicBehavior
Message consumptionEach message delivered to all subscribers
Message lifetimeVaries—often transient or short-lived
Consumer coordinationIndependent—each subscriber receives everything
Replay capabilityLimited or not supported

Pub/sub systems enable broadcasting: notifications, updates, and events that multiple systems need to observe. Traditional implementations include JMS topics and cloud pub/sub services.

Kafka implements a distributed commit log: an ordered, append-only sequence of records that is retained for a configurable period. Consumers read from the log at their own pace, tracking their position (offset) independently.

CharacteristicBehavior
Message consumptionConsumers read from the log independently
Message lifetimeRetained based on time or size policy
Consumer coordinationConsumer groups enable both broadcast and work distribution
Replay capabilityFull replay from any retained offset

The log model provides unique capabilities:

  • Decoupling in time: Consumers can process events long after they were produced
  • Multiple consumer patterns: Same data serves real-time processing, batch analytics, and audit
  • Replay and reprocessing: Consumers can reset to earlier offsets to reprocess historical data
  • Ordering guarantees: Events within a partition maintain strict ordering

Replayability is bounded by retention and compaction policies configured per topic.


Kafka uses specific terminology that reflects its log-based architecture.

TermDefinition
EventA fact that occurred at a point in time—immutable and timestamped
RecordKafka’s unit of data: key, value, timestamp, headers, offset
MessageOften used interchangeably with record
TopicA named category or feed of records
PartitionAn ordered, immutable sequence of records within a topic
OffsetA unique sequential identifier for each record within a partition

Every Kafka record contains:

Fields of a Kafka recordFields of a Kafka recordKafka RecordKey (optional)Value (payload)TimestampHeaders (optional)Offset (assigned by broker)Used for:- Partitioning- Log compaction- Ordering related eventsThe event payload- Serialized bytes- Schema-managed (Avro, Protobuf, JSON)Partition-local sequence number- Assigned on append- Never reused- Used for consumption tracking
FieldRequiredPurpose
KeyNoDetermines partition assignment; used for compaction
ValueYesThe event payload
TimestampYesEvent time or ingestion time
HeadersNoMetadata key-value pairs
OffsetAssignedSequential position within partition

Kafka organizes data into topics—named feeds that producers write to and consumers read from. Each topic is divided into partitions, enabling horizontal scalability and parallel processing. Replication across brokers provides fault tolerance.

ConceptPurpose
TopicNamed category for related records
PartitionOrdered, append-only log segment enabling parallelism
ReplicationCopies across brokers for fault tolerance
OffsetSequential position of a record within a partition

Key guarantees:

  • Records within a partition maintain strict ordering
  • Records with the same key are routed to the same partition
  • Partition count determines maximum consumer parallelism

For comprehensive coverage of topic architecture, partitioning strategies, replication, and configuration, see Topics.


Consumer groups enable Kafka to support both broadcast (pub/sub) and work distribution (queue) patterns with a single mechanism.

Partition assignment across two consumer groups reading one topicPartition assignment across two consumer groups reading one topicTopic: events (4 partitions)Consumer Group A(analytics)Consumer Group B(notifications)P0P1P2P3Consumer A1Consumer A2Consumer B1Work distribution:partitions split acrossconsumers in same groupSingle consumer readsall partitions
PatternConfigurationBehavior
Work distributionMultiple consumers in same groupEach partition assigned to exactly one consumer
BroadcastDifferent consumer groupsEach group receives all messages independently
Competing consumersMore consumers than partitionsExtra consumers remain idle (standby)

Each consumer group tracks its position in each partition independently:

Offset TypeDefinition
Current offsetNext record to be fetched by consumer
Committed offsetLast successfully processed record (persisted to __consumer_offsets topic)
Log end offsetLatest record in the partition
Consumer lagDifference between log end offset and committed offset

Consumer lag is a critical operational metric—growing lag indicates consumers cannot keep up with production rate.


Kafka distinguishes between when an event occurred and when it is processed.

Time ConceptDefinitionUse Case
Event timeWhen the event actually occurred (embedded in record)Analytics, time-windowed aggregations
Ingestion timeWhen the broker received the recordSimpler processing when event time unavailable
Processing timeWhen the consumer processes the recordTriggering actions, real-time alerting

Event time is essential for accurate analytics—processing delays, consumer restarts, or replays should not affect time-based calculations.

SettingBehavior
CreateTime (default)Timestamp set by producer (event time or producer clock)
LogAppendTimeTimestamp set by broker on receipt

AspectTraditional Message QueueKafka Event Streaming
Message lifetimeDeleted after consumptionRetained based on policy
ReplayNot supportedSupported via offset reset
Consumer couplingConsumers must be onlineConsumers can catch up later
Multiple consumersRequires separate queuesSingle topic, multiple groups
Message orderingOften FIFO per queuePartition-scoped
ThroughputVaries by broker and configurationVaries by broker and configuration
Primary use caseTask distributionEvent streaming, data integration

Event streaming with Kafka is well-suited for:

Use CaseWhy Kafka
Real-time data pipelinesHigh throughput, exactly-once processing within Kafka, connector ecosystem
Event-driven microservicesDecoupling, replay capability, event sourcing support
Event persistenceLog compaction, exactly-once semantics, connector sinks
Stream processingKafka Streams for stateful processing
Data integrationKafka Connect connector ecosystem
Audit loggingImmutable log, long retention, compliance

Event streaming may not be the best fit for:

ScenarioWhy Not
Simple request-responseHTTP/REST is simpler
Small scale, low throughputKafka adds operational overhead
Strict message ordering across all dataOrdering is partition-scoped
Complex routing logicTraditional message brokers may be more flexible