Kafka provide server level properties for configuration of Broker, Socket, Zookeeper, Buffering, Retention etc.
broker.id : This broker id which is unique integer value in Kafka cluster.
broker.id:0
Socket Server Settings :
listeners: default value is PLAINTEXT://:9092 where socket servers listens and if not configured will take from java.net.InetAddress.getCanonicalHostName()
Format: security_protocol://host_name:port
listeners:PLAINTEXT://:9092
advertised.listeners: Need to set this value if listeners value is not set. Broker will advertise this listener value to producers and consumers.
Example: PLAINTEXT://your.host.name:9092
advertised.listeners:PLAINTEXT://:9092
num.network.threads: Threads handling network requests.
num.network.threads:3
num.io.threads: Number of threads handling I/O for disk.
num.io.threads:8
socket.send.buffer.bytes: Buffer size used by socket server to keep records for sending.
socket.send.buffer.bytes:102400
socket.receive.buffer.bytes: Buffer size used by socket server to keep records for sending.
socket.receive.buffer.bytes:102400
socket.request.max.bytes: max size of request that the socket server will accept.
socket.request.max.bytes:104857600
Log Basics
log.dirs: a comma separated list of directories under which to store log files.
log.dirs=/tmp/kafka-logs
num.partitions: The default number of logs per topic. More partitions allow greater parallelism for consumption, but this will also result in more files across the brokers.
num.partitions=1
num.recovery.threads.per.data.dir: The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1
Log Flush Policy
log.flush.interval.messages: Messages are immediately written to the file system but by default we only fsync() to sync the OS cache lazily. The following configurations control the flush of data to disk.There are a few important trade-offs here:
- Durability: Unflushed data may be lost if you are not using replication.
- Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
- Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.
The settings below allow one to configure the flush policy to flush data after a period of time or every N messages (or both). This can be done globally and overridden on a per-topic basis.
The number of messages to accept before forcing a flush of data to disk.
log.flush.interval.messages=10000
The maximum amount of time a message can sit in a log before we force a flush.
log.flush.interval.ms=1000
Log Retention Policy
The following configurations control the disposal of log segments. The policy can be set to delete segments after a period of time, or after a given size has accumulated. A segment will be deleted whenever either of these criteria are met. Deletion always happens from the end of the log.
log.retention.hours:The minimum age of a log file to be eligible for deletion
log.retention.hours=168
log.retention.bytes:A size-based retention policy for logs. Segments are pruned from the log as long as the remaining segments don’t drop below log.retention.bytes.
log.retention.bytes=1073741824
log.segment.bytes:The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=1073741824
log.retention.check.interval.ms: The interval at which log segments are checked to see if they can be deleted according to the retention policies
log.retention.check.interval.ms=300000
Zookeeper
zookeeper.connect: Zookeeper connection string is a comma separated host:port pairs, each corresponding to a zk server. e.g. “127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002”. We can also append an optional root string to the urls to specify theroot directory for all kafka znodes.
zookeeper.connect=localhost:2181
zookeeper.connection.timeout.ms: Timeout in ms for connecting to zookeeper.
zookeeper.connection.timeout.ms=6000
Read More on Kafka
- Kafka Introduction and Architecture
- Setup Kafka Cluster for Single Server/Broker
- Setup Kafka Cluster for Multi/Distributed Servers/Brokers
- Integrate Java with Kafka
- Integrate Logstash with Kafka
- Integrate Filebeat with Kafka
- Kafka and Zookeeper Common Issues
Integration
Integrate Filebeat, Kafka, Logstash, Elasticsearch and Kibana
6 thoughts on “Kafka Server Properties Configuration”
You must log in to post a comment.