Kafka 一些优化措施

线程数

在kafka/config/server.properties中配置

#计算密集任务所需线程
# The number of threads that the server uses for receiving requests from the network and sending responses to the network
num.network.threads=3
#IO密集任务所需线程
# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8

如果服务器cpu核心为 X ,那么

    计算密集任务所需线程 =  X

    IO密集任务所需线程 = 2 * X

消息保存时限

在kafka/config/server.properties中配置

# The minimum age of a log file to be eligible for deletion due to age
log.retention.hours=168

一般日志服务器会保留数据30天,所以没必要kakfa保存7天,3天就够了,,如果数据丢失可以从日志服务器中取

开启压缩

在kafka/config/producer.properties中配置

# specify the compression codec for all data generated: none, gzip, snappy, lz4
compression.type=none

默认是不开启压缩,支持格式有,gzip,snappy,lz4

内存

在 kafka/bin/kafka-server-start.sh  中配置

扫描二维码关注公众号,回复: 10856415 查看本文章

 默认1G,生产中的经验值为4 到 6 G,

  最高6G,超过6G效果不明显,这时建议加服务器

猜你喜欢

转载自www.cnblogs.com/yangxusun9/p/12713784.html