Skip to main content

Configuration

Environment Variables

Core Configuration

VariableDescriptionDefault
KAFKA_NODE_IDUnique node identifier1
KAFKA_PROCESS_ROLESComma-separated roles: broker, controllerbroker,controller
KAFKA_CLUSTER_IDCluster identifier (must be same on all nodes)Auto-generated
KAFKA_CONTROLLER_QUORUM_VOTERSController quorum voters (format: id@host:port[,...])1@localhost:9093
KAFKA_CONTROLLER_LISTENER_NAMESController listener nameCONTROLLER

Network Configuration

VariableDescriptionDefault
KAFKA_LISTENERSListener configurationPLAINTEXT://:9092,CONTROLLER://:9093
KAFKA_ADVERTISED_LISTENERSAdvertised listeners for clientsPLAINTEXT://localhost:9092
KAFKA_INTER_BROKER_LISTENER_NAMEInter-broker listener namePLAINTEXT
KAFKA_LISTENER_SECURITY_PROTOCOL_MAPSecurity protocol mappingCONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,...

Performance Configuration

VariableDescriptionDefault
KAFKA_NUM_NETWORK_THREADSNumber of network threads3
KAFKA_NUM_IO_THREADSNumber of I/O threads8
KAFKA_NUM_PARTITIONSDefault number of partitions1
KAFKA_NUM_RECOVERY_THREADS_PER_DATA_DIRRecovery threads per data dir1
KAFKA_SOCKET_SEND_BUFFER_BYTESSocket send buffer size102400
KAFKA_SOCKET_RECEIVE_BUFFER_BYTESSocket receive buffer size102400
KAFKA_SOCKET_REQUEST_MAX_BYTESMax socket request size104857600

Storage Configuration

VariableDescriptionDefault
KAFKA_LOG_DIRSLog directories/opt/kafka/data
KAFKA_LOG_RETENTION_HOURSLog retention period (hours)168
KAFKA_LOG_SEGMENT_BYTESLog segment size1073741824
KAFKA_LOG_RETENTION_CHECK_INTERVAL_MSRetention check interval300000

Replication Configuration

VariableDescriptionDefault
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOROffsets topic replication factor1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTORTransaction log replication factor1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISRMinimum in-sync replicas1

Topic Configuration

VariableDescriptionDefault
KAFKA_AUTO_CREATE_TOPICS_ENABLEAuto-create topicstrue
KAFKA_DELETE_TOPIC_ENABLEAllow topic deletiontrue
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MSGroup rebalance delay0

Custom Properties

Any Kafka property can be set using the KAFKA_CONFIG_ prefix:

environment:
KAFKA_CONFIG_LOG_CLEANER_ENABLE: "true"
KAFKA_CONFIG_LOG_RETENTION_BYTES: "1073741824"
KAFKA_CONFIG_MAX_REQUEST_SIZE: "10485760"
KAFKA_CONFIG_MESSAGE_MAX_BYTES: "1048588"
KAFKA_CONFIG_REPLICA_FETCH_MAX_BYTES: "1048576"
KAFKA_CONFIG_MAX_CONNECTIONS_PER_IP: "2147483647"

This translates to:

  • log.cleaner.enable=true
  • log.retention.bytes=1073741824
  • max.request.size=10485760
  • message.max.bytes=1048588
  • replica.fetch.max.bytes=1048576
  • max.connections.per.ip=2147483647

Listener Configuration Example

For multiple listener configurations:

environment:
KAFKA_LISTENERS: "PLAINTEXT://:9092,CONTROLLER://:9093"
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://kafka:9092"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT"
KAFKA_INTER_BROKER_LISTENER_NAME: "PLAINTEXT"