簡體   English   中英

Kafka Mirrormaker2配置優化

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM