[英]How to pass Apache Kafka Mirrormaker2 config for the producer
[英]Kafka Mirrormaker2 config optimization
我正在我们的测试环境中设置 Strimzi kafka Mirrormaker2,它平均每 5 分钟接收 100k 条消息。 对于这些主题,我们总共有大约 25 个主题和 900 个分区。 我设置的默认配置是仅将 60k 消息/5 分钟镜像到 DR 集群。 我正在尝试优化此配置以获得更好的吞吐量和延迟。
apiVersion: v1
items:
- apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaMirrorMaker2
spec:
clusters:
- alias: source
authentication:
certificateAndKey:
certificate: user.crt
key: user.key
secretName: mirrormaker1
type: tls
bootstrapServers: bootstrap1:443
tls:
trustedCertificates:
- certificate: ca.crt
secretName: cert-source
- alias: target
authentication:
certificateAndKey:
certificate: user.crt
key: user.key
secretName: mirrormaker-dr
type: tls
bootstrapServers: bootstrap2:443
config:
offset.flush.timeout.ms: 120000
tls:
trustedCertificates:
- certificate: ca.crt
secretName: dest-cert
connectCluster: target
livenessProbe:
initialDelaySeconds: 40
periodSeconds: 40
timeoutSeconds: 30
metricsConfig:
type: jmxPrometheusExporter
valueFrom:
configMapKeyRef:
key: mm2-metrics-config.yaml
name: mm2-metrics
mirrors:
- checkpointConnector:
config:
checkpoints.topic.replication.factor: 3
tasksMax: 10
groupsPattern: .*
heartbeatConnector:
config:
heartbeats.topic.replication.factor: 3
sourceCluster: source
sourceConnector:
config:
consumer.request.timeout.ms: 150000
offset-syncs.topic.replication.factor: 3
refresh.topics.interval.seconds: 60
replication.factor: 3
source.cluster.producer.enable.idempotence: "true"
sync.topic.acls.enabled: "true"
target.cluster.producer.enable.idempotence: "true"
tasksMax: 60
targetCluster: target
topicsPattern: .*
readinessProbe:
initialDelaySeconds: 40
periodSeconds: 40
timeoutSeconds: 30
replicas: 4
resources:
limits:
cpu: 9
memory: 30Gi
requests:
cpu: 5
memory: 15Gi
version: 2.8.0
使用上述配置,我在日志文件中看不到任何错误。
我尝试微调配置以获得更多吞吐量和延迟,如下所示
consumer.max.partition.fetch.bytes: 2097152
consumer.max.poll.records: 1000
consumer.receive.buffer.bytes: 131072
consumer.request.timeout.ms: 200000
consumer.send.buffer.bytes: 262144
offset-syncs.topic.replication.factor: 3
producer.acks: 0
producer.batch.size: 20000
producer.buffer.memory: 30331648
producer.linger.ms: 10
producer.max.request.size: 2097152
producer.message.max.bytes: 2097176
producer.request.timeout.ms: 150000
我现在在日志中看到以下错误,但数据仍在流动,并且看到消息数量略微增加到 ~65k/5 分钟左右。 我还将 taskmax 计数从 60 增加到 800,将副本从 4 增加到 8,但我看不出这样做有什么区别。此外,N/w 字节数约为 20 MiB/s。 即使我进一步增加了 consumer.request.timeout.ms 以下错误并没有消失..
2022-04-26 04:09:51,223 INFO [Consumer clientId=consumer-null-1601, groupId=null] 向节点 4 发送获取请求 (sessionId=629190882, epoch=65) 时出错: (org.apache.kafka.clients .FetchSessionHandler) [任务线程-us-ashburn-1->us-phoenix-1-dr.MirrorSourceConnector-759] org.apache.kafka.common.errors.DisconnectException
我能做些什么来增加吞吐量和减少延迟吗?
我以前没有配置过 Strimzi kafka Mirrormaker,但乍一看,生产者和消费者配置似乎与kafka-clients
库公开的配置相同。 假设是这种情况,设置为 20000 的生产者的batch.size
不是记录数。 它以字节为单位,这意味着使用此配置,生产者每次发送最多只能传输 20 KB。 尝试将其增加到 65,536(64 KB)或更高。 如果吞吐量仍然没有增加,将linger.ms
增加到100
或更高,以便生产者在触发发送之前等待更长的时间等待每个批次填满
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.