Configuring Broker Settings

1. Setting Broker ID

Config Description Detail
node.id KRaft unique identifier Integer
broker.id Legacy ZK identifier LEGACY
Uniqueness Must differ per broker Cluster-wide

Example: Broker id

node.id=3

2. Configuring Listeners

Config Description Example
listeners Bind endpoints PLAINTEXT://:9092
advertised.listeners Client-facing endpoints host:9092
inter.broker.
listener.name
Internal traffic listener INTERNAL

Example: Listener config

listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://broker3.example.com:9092

3. Setting Log Directories

Config Description Tip
log.dirs Data directories One per disk
num.recovery.
threads.per.data.dir
Startup recovery parallelism Faster boot
Balance Partitions spread by free space Auto

Example: Multiple disks

log.dirs=/data1/kafka,/data2/kafka
num.recovery.threads.per.data.dir=2

4. Configuring Number of Threads

Config Description Default
num.network.threads Handle network requests 3
num.io.threads Disk IO request handlers 8
background.threads Misc background tasks 10

Example: Thread tuning

num.network.threads=6
num.io.threads=16

5. Setting Socket Buffer Sizes

Config Description Default
socket.send.
buffer.bytes
TCP send buffer 102400
socket.receive.
buffer.bytes
TCP receive buffer 102400
socket.request.
max.bytes
Max request size 104857600

Example: Larger socket buffers

socket.send.buffer.bytes=1048576
socket.receive.buffer.bytes=1048576

6. Configuring Max Message Size

Config Description Default
message.max.bytes Max record batch size 1048588
replica.fetch.
max.bytes
Must ≥ message.max.bytes Align
Client max.request.size matched Both sides

Example: Allow large messages

message.max.bytes=5242880
replica.fetch.max.bytes=5242880

7. Setting Default Replication Factor

Config Description Prod Value
default.replication.factor Auto-created topics 3
offsets.topic.
replication.factor
__consumer_offsets RF 3
transaction.state.log.
replication.factor
Tx log RF 3

Example: Replication defaults

default.replication.factor=3
offsets.topic.replication.factor=3
transaction.state.log.replication.factor=3

8. Configuring Min ISR

Config Description Recommended
min.insync.replicas Broker default min ISR 2
With acks=all Enforces durability Pair
Override Per-topic config Critical topics

Example: Default min ISR

min.insync.replicas=2

9. Setting Unclean Leader Election

Config Description Default
unclean.leader.
election.enable
Allow out-of-sync leader false
false No data loss, may halt Safe
true Availability over durability Risky

Example: Keep unclean disabled

unclean.leader.election.enable=false

10. Configuring Log Retention

Config Description Default
log.retention.hours Default retention 168 (7d)
log.retention.bytes Per-partition size cap -1
log.retention.
check.interval.ms
Cleanup scan interval 300000

Example: Retention defaults

log.retention.hours=72
log.retention.bytes=10737418240

11. Setting Log Segment Size

Config Description Default
log.segment.bytes Segment file size 1073741824
log.roll.hours Time-based roll 168
log.index.size.
max.bytes
Max index size 10485760

Example: Segment size

log.segment.bytes=536870912

12. Configuring Log Cleanup

Config Description Default
log.cleanup.policy delete / compact delete
log.cleaner.enable Enable compaction true
log.cleaner.threads Cleaner threads 1

Example: Cleanup policy

log.cleanup.policy=delete
log.cleaner.enable=true