Does Kafka have a visibility timeout?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka, a popular distributed streaming platform, fundamentally differs from traditional message queuing systems in several ways, including how it handles message visibility and processing. Unlike systems such as Amazon SQS that have a concept of "visibility timeout," Kafka operates based on a different model which focuses on log retention.
Understanding Kafka's Message Model
Kafka stores messages in topics which are divided into partitions. Each partition is an ordered, immutable sequence of messages that is continually appended to. Producers write messages to these partitions and consumers read messages from them. Importantly, the messages are not deleted after consumption. Instead, they are retained according to a configurable retention policy, which could be based on time or size.
Consumer Offsets and Message Processing
In Kafka, each consumer in a consumer group tracks its position in each partition via something called an offset. This offset marks the location of the consumer in the log. Consumers have the control to manage their offsets and may even reprocess messages by resetting the offset. This mechanism does not hide messages from other consumers while one consumer is processing it; rather, it allows multiple consumers to read the same message independently if they so choose.
Comparison with Visibility Timeout Concept
In queue systems like Amazon SQS, the visibility timeout is a crucial feature. This timeout hides a message from other workers once a worker has picked it up for processing. If the processing is completed within the timeout, the message is deleted. If not, the message becomes visible again so that other workers can pick it up.
This concept does not exist in Kafka because Kafka relies on the concept that messages are not "picked up" or "locked" but are read. Since Kafka allows storing large volumes of messages and processing them at different speeds depending on consumer capability, it aligns more with a high-throughput use case where the same message might need to be consumed multiple times independently.
Implications for Kafka Users
For Kafka users, this model means understanding that once a message is committed to a Kafka topic, it is potentially visible to all consumers who have access to the topic, depending on their offset. This architectural decision simplifies Kafka's design but puts more responsibility on the consumers to handle message processing correctly, particularly in multi-consumer environments.
Technical Example
Imagine a scenario where two consumers, ConsumerA and ConsumerB, are reading from the same Kafka topic. If ConsumerA reads a message but fails to process it correctly, it will still move its offset forward. In contrast, ConsumerB might process the same message successfully. If ConsumerA has issues, it can reset its offset back to reprocess the message — without affecting ConsumerB.
Summary Table
| Feature | Kafka | Systems with Visibility Timeout like SQS |
| Message Consumption Model | Read based, with independent offsets | Message locking during processing |
| Multiple Reads | Allowed and independent | Typically not without re-queuing |
| Message Visibility | Controlled by retention policy | Controlled by visibility timeout |
| Consumer Failure Handling | Offset reset for reprocessing | Visibility timeout expiration |
| Use Case Fit | High throughput, re-readability | Discrete handling, less reprocessing |
Conclusion
Kafka’s design does not include a visibility timeout feature because it employs a fundamentally different model of message consumption. While this results in high flexibility and scalability, it also requires developers and system architects to carefully design their consumers’ offset management and error handling strategies. Understanding these differences is crucial for leveraging Kafka effectively in a distributed system.
Related reading
- Does kafka have any default web UI
- Does Kafka python API support stream processing?
- Does Kafka rebalancing algorithm balance across topics?
- Does Kafka Streams aggregation stage serialize and deserialize each single element?
- Does Kafka support ELB in front of broker cluster?
- Does Kafka support priority for topic or message?
- Does Kafka support java 10 or java 11?
- Does Kafka support request response messaging

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.