Skip to content

ref: decrease Kafka log retention hours - #4442

Open
aldy505 wants to merge 1 commit into
masterfrom
aldy505/ref/decrease-kafka-log-retention-hours
Open

ref: decrease Kafka log retention hours#4442
aldy505 wants to merge 1 commit into
masterfrom
aldy505/ref/decrease-kafka-log-retention-hours

Conversation

@aldy505

@aldy505 aldy505 commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

This is coming from a discussion from @jan-auer on Slack. He figured that it would be fine (or perhaps better) if the retention hours is set to 1 hour. I have a personal argument that 1 hour might not be enough for folks running in bigger volume and therefore slower processing time, therefore this 3 hours is a compromise.

To apply the change, the easiest way is to delete the Kafka volume, and let the install.sh script recreate it. But you can also do it manually using the kafka CLI:

for topic in $(docker compose exec kafka kafka-topics \
  --bootstrap-server kafka:9092 \
  --list); do
  docker compose exec kafka kafka-configs \
    --bootstrap-server kafka:9092 \
    --entity-type topics \
    --entity-name $topic \
    --alter \
    --add-config retention.ms=86400000
done

This is coming from a discussion from @jan-auer on Slack. He figured that it would be fine (or perhaps better) if the retention hours is set to 1 hour. I have a personal argument that 1 hour might not be enough for folks running in bigger volume and therefore slower processing time, therefore this 3 hours is a compromise.

To apply the change, the easiest way is to delete the Kafka volume, and let the `install.sh` script recreate it. But you can also do it manually using the kafka CLI:

```bash
for topic in $(docker compose exec kafka kafka-topics \
  --bootstrap-server kafka:9092 \
  --list); do
  docker compose exec kafka kafka-configs \
    --bootstrap-server kafka:9092 \
    --entity-type topics \
    --entity-name $topic \
    --alter \
    --add-config retention.ms=86400000
done
````
Comment thread docker-compose.yml
# Lower the log retention to 1 hours to avoid filling up the disk,
# ONLY IF you have fast processing time and/or small data volumes.
# Otherwise, you can set it to a higher value if you have much slower
# processing time and/or larger data volumes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The manual migration script in the PR description uses an incorrect retention.ms value (24 hours) instead of the intended 3 hours.
Severity: MEDIUM

Suggested Fix

In the pull request description, correct the manual migration command to use retention.ms=10800000 instead of retention.ms=86400000 to align with the intended 3-hour retention period.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: docker-compose.yml#L216

Potential issue: The manual migration script provided in the pull request description
contains an incorrect value. It instructs users to set `retention.ms` to `86400000`,
which is 24 hours, instead of the intended 3 hours. Users who follow this manual
migration path will not get the benefit of the reduced log retention, as the topic-level
configuration will override the new 3-hour broker-level default. This undermines the
primary goal of the pull request, which is to reduce disk usage.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment thread docker-compose.yml
KAFKA_OFFSETS_TOPIC_NUM_PARTITIONS: "1"
KAFKA_LOG_RETENTION_HOURS: "24"
# Lower the log retention to 1 hours to avoid filling up the disk,
# ONLY IF you have fast processing time and/or small data volumes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For small data volumes, 1 hour and 3 hours do not make much of a difference.

I would say let's make 3 hours default and keep higher value note below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants