liveBook · Manning

Timestamp

As explained in Kafka for Architects

A message timestamp is the time value associated with a Kafka message for determining its retention age.

A Kafka message includes a timestamp alongside its key, value, and other metadata. For time-based retention, that timestamp helps determine when the message is old enough to remove. The timestamp source is therefore an architectural choice, not just a producer detail. section 2.4.1 section 2.4.5

Two timestamp sources have different operational consequences:

  • CreateTime is set by the producer. An inaccurate producer clock can cause premature deletion or unnecessarily long retention. Brokers can reject producer timestamps outside ranges set by log.message.timestamp.after.max.ms and log.message.timestamp.before.max.ms. section 2.4.5 section 3.2.6
  • LogAppendTime is assigned when the broker receives the message, making deletion more predictable. When messages are batched and compressed, however, a single LogAppendTime timestamp can represent the whole batch rather than each message’s individual time. section 2.4.5 section 3.2.6

Plan for a disconnected consumer

If a consumer may be disconnected for one day, retain its messages for longer than a day, with a margin. Using LogAppendTime gives retention a broker-assigned reference point; keep the client’s original time in the payload when that time matters to the business. section 2.4.5

Do not confuse a message timestamp with event time. A transaction may carry a business timestamp in its payload, while Kafka Streams ordinarily processes records in partition-offset order; timestamps can appear out of order because of producer delays or clock differences. To base Kafka Streams logic on embedded event time, implement a TimestampExtractor. Agree on timestamp sources across systems so retention and processing use the intended meaning of time. section 3.2.2 section 8.5.3 section 3.2.6

How Kafka for Architects covers it

How deep it goes
Explains timestamp sources, producer-clock risks, broker bounds, and batch behavior without a low-level implementation walkthrough.
Examples
Uses a one-day consumer disconnection, inaccurate producer clocks, batched messages, and transaction business timestamps.
What it assumes
Introduces timestamps as message metadata while relying on producer, broker, topic, and partition terminology.
What you can do after
Operate/configure it by choosing a timestamp source, checking producer-time bounds, and preserving client time when needed.
How it connects
Connects timestamps to retention, log compaction, batching, partition offsets, event time, and Kafka Streams.

Also explained in

Compare how 10 books explain timestamp →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka for Architects. The section links point to the parts of the book it draws on.