Kafka 参数调优

Kafka 生产调优参数:
Producer: 
acks: all

buffer.memory: 536870912

compression.type :snappy

retries: 100
        max.in.flight.requests.per.connection = 1

batch.size: 10000 字节 不是条数
        max.request.size = 2097152
request.timeout.ms = 360000    大于 replica.lag.time.max.ms 
metadata.fetch.timeout.ms= 360000
timeout.ms = 360000

linger.ms 5s (生产不用)

max.block.ms 1800000

Broker: CDH
message.max.bytes 2560KB  1条消息的大小
zookeeper.session.timeout.ms 180000
replica.fetch.max.bytes 5M   大于message.max.bytes
num.replica.fetchers 6
replica.lag.max.messages 6000
replica.lag.time.max.ms 15000

log.flush.interval.messages 10000
log.flush.interval.ms 5s

Consumer:
https://issues.apache.org/jira/browse/SPARK-22968
        , "max.partition.fetch.bytes" -> (5242880: java.lang.Integer) //default: 1048576
, "request.timeout.ms" -> (90000: java.lang.Integer) //default: 60000
, "session.timeout.ms" -> (60000: java.lang.Integer) //default: 30000
, "heartbeat.interval.ms" -> (5000: java.lang.Integer)
, "receive.buffer.bytes" -> (10485760: java.lang.Integer)

Minor changes required for Kafka 0.10 and the new consumer compared to laughing_man's answer:

Broker:   No changes, you still need to increase properties message.max.bytes 
          and replica.fetch.max.bytes. message.max.bytes has to be equal or smaller(*) than 
  replica.fetch.max.bytes.
Producer: Increase max.request.size to send the larger message.
Consumer: Increase max.partition.fetch.bytes to receive larger messages.
(*) Read the comments to learn more about message.max.bytes<=replica.fetch.max.bytes

2.消费者的值
ConsumerRecord(
topic = onlinelogs, partition = 0, 
offset = 1452002, CreateTime = -1, checksum = 3849965367, 
serialized key size = -1, serialized value size = 305, 

key = null, 
value = {"hostname":"yws76","servicename":"namenode",
"time":"2018-03-21 20:11:30,090","logtype":"INFO",
"loginfo":
"org.apache.hadoop.hdfs.server.namenode.FileJournalManager:
Finalizing edits file /dfs/nn/current/edits_inprogress_0000000000001453017 -> /dfs/nn/current/edits_0000000000001453017-0000000000001453030"})

2.1解释前面讲的曲线图
2.2 key=null;
    分区策略,

Key is not null: Utils.abs(key.hashCode) % numPartitions
key=null: 
http://www.2bowl.info/kafka%E6%BA%90%E7%A0%81%E8%A7%A3%E8%AF%BB-key%E4%B8%BAnulll%E6%97%B6kafka%E5%A6%82%E4%BD%95%E9%80%89%E6%8B%A9%E5%88%86%E5%8C%BApartition/

3.1
记录自定义kafka的parcel库,CDH安装kafka服务,无法安装过去的排雷过程
http://blog.itpub.net/30089851/viewspace-2136372/

3.2
断电 ,导致Kafka的Topic的损坏
现象:  CDH web界面,Kafka进程绿色,我们一般认为绿色就是进程ok,其实不然
       生产者和消费者 无法work,抛exception

流程:
      去机器上看broker日志
        kafka.common.NotAssignedReplicaException: 
Leader 186 failed to record follower 191's position -1 
since the replica is not recognized to be one of the assigned replicas 186 
for partition [__consumer_offsets,3].

1.服务down,broker节点的kafka log目录删除
2.zk的kafka的元数据
3.重新装个kafka和topic

思考:
1.重刷,数据重复怎么办?
      HBase put api(insert+update)

2.假如数据是落在HDFS,思考?
Hive 支持update,从哪个版本?加什么参数?

3.分区内保证排序的,多个分区怎样保证排序? 0.11版本 
insert 
delete
insert --> delete
delete --> insert
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Kafka 3.4.0 是一个比较老的版本,但是参数调优的方法基本上和较新版本相同。下面是一些可以考虑的参数调优: 1. 增加分区数:增加分区数可以提高 Kafka 集群的吞吐量。但是,增加分区数也会增加管理和维护的复杂性。在增加分区数之前,需要评估分区数对集群的影响。 2. 调整副本数:副本数决定了数据的冗余度,也影响了 Kafka 集群的可用性。增加副本数可以提高数据的可靠性,但是也会增加网络带宽的使用和磁盘空间的占用。在调整副本数之前,需要评估副本数对集群的影响。 3. 调整 batch.size 和 linger.ms:batch.size 和 linger.ms 参数控制了消息发送的批处理方式。batch.size 参数控制了批处理的消息数量,linger.ms 参数控制了消息在缓冲区等待的时间。调整这些参数可以提高 Kafka 集群的吞吐量。 4. 增加 JVM 堆内存:Kafka 使用 JVM 运行,因此增加 JVM 堆内存可以提高 Kafka 集群的性能。但是,增加 JVM 堆内存也会增加 GC 的开销。在增加 JVM 堆内存之前,需要评估 JVM 堆内存对集群的影响。 5. 调整网络缓冲区大小:Kafka 使用网络传输消息,因此调整网络缓冲区大小可以提高 Kafka 集群的性能。但是,调整网络缓冲区大小也会增加网络带宽的使用。在调整网络缓冲区大小之前,需要评估网络缓冲区大小对集群的影响。 这些都是一些常见的参数调优方法,但是对于不同的 Kafka 集群,需要根据实际情况进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值