1. 前言
最近项目现场发生了 日志文件积压的情况,日志文件的大概处理流程是:读取日志文件->进行结构化->发送到 kafka
以一个 7.57M的日志文件为例(约58400条日志信息),程序需要 16.8s才能将其处理完,也就是说平均每秒只能处理约 3500条数据,经过验证,其中瓶颈在数据发送到 Kafka这一步。这个根据经验,明显肯定是没有达到 Kafka的瓶颈的,应该是自己 producer程序有问题,于是去 Kafka官网一查:
Single producer thread, 3x asynchronous replication
786,980 records/sec
(75.1 MB/sec)
跟官网给出的性能数据一比,那就老老实实去找自己程序的问题吧。
根据经验,第一个想到的就是去进行客户端参数调优。接下来就介绍下 kafka producer的重要配置项,然后给出参数调优的方案和最终结果。
2. Kafka Producer重要配置项
2.1 batch.size
The producer will attempt to batch records together into fewer requests whenever multiple records are being sent to the same partition. This helps performance on both
the client and the server. This configuration controls the default batch size in bytes.
No attempt will be made to


8320

被折叠的 条评论
为什么被折叠?



