Current state: Discussion
Discussion thread: here
Vote thread: here
JIRA: KAFKA-19893
PR: https://github.com/apache/kafka/pull/20913
Currently, Kafka's tiered storage implementation uploads all non-active local log segments to remote storage immediately, even when they are still within the local retention period.
This results in redundant storage of the same data in both local and remote tiers.
When there is no requirement for real-time analytics or immediate consumption based on remote storage. It has the following drawbacks:
1. Wastes storage capacity and costs: The same data is stored twice during the local retention window
2. Provides no immediate benefit: During the local retention period, reads prioritize local data, making the remote copy unnecessary
Example scenario and this KIP's goal:
Consider a topic with remote storage enable:
- Local retention: 1 day (24 hours)
- Remote retention: 3 days (72 hours)
Data is stored in both tiers for the first day, resulting in about 16 hours of redundant storage. This can leads to cost waste.
So we can reduce the tiered storage redundancy for cost saving. In this case, it will save about 25% cost payment for total size of disk.

However, some users/topics rely on remote storage for real-time analytics and need the latest data to be available as soon as possible
(In fact, it only tries to stay as up-to-date as possible, but it still can’t include the latest data because the active segment hasn’t been uploaded yet.).
Therefore, this optimization is offered as a topic's optional configuration rather than the default behavior.
This KIP introduces one new topic configuration item: remote.log.keep.latest
BTW: topic's remote storage already had some others items such as remote.log.delete.on.disable/remote.log.copy.disable, etc.
public static final String REMOTE_LOG_KEEP_LATEST_CONFIG = "remote.log.keep.latest";
public static final String REMOTE_LOG_KEEP_LATEST_DOC = "Determines whether to upload all segments to remote storage including the latest ones within local retention. " +
"When set to true (default), all committed segments will be uploaded without checking local retention constraints. " +
"When set to false, only segments beyond local retention period will be uploaded to remote storage."; |
The default value is true so that the whole remote storage module keeps the original behavior when topic don't set it to false.
You can refer to https://github.com/apache/kafka/pull/20913 for the detailed changes.
We change the RemoteLogManager.RLMCopyTask#candidateLogSegments's logic for decide one segment if need to upload to remote:

You can see the uploading will be delayed if the configure remoteLogKeepLatest is false. And After the change, the remote tiered storage redundancy will be reduced with delayed upload.
You can refer to the test case and result: https://github.com/apache/kafka/pull/20913#issuecomment-3547156286
BTW: Here are some additional thoughts/considerations.
Backward Compatibility
This change is fully compatible:
Backward compatible: Default value (true) maintains current behavior
Forward compatible: Older clients unaware of this config will ignore it
We can use follow tests to cover the change:
Unit Tests:
Integration Tests:
Alternative 1: Make this the default behavior
Reason for rejection: Some users require real-time remote analytics and need data uploaded as soon as possible. Breaking their use case would be unacceptable. after all it is the default behavior before this change.
Alternative 2: Global broker-level configuration only
Reason for rejection: Different topics have different requirements. Topic-level granularity is essential.