KStreams 在 Spring Cloud Stream 中运行速度非常慢

问题描述 投票:0回答:1

我已经在 Spring boot 中使用 SpringCloudStreams 实现了 KStreams。 我已准备好从具有 20 个分区的主题写入具有相同分区数的主题。我有 2 个 Pod 正在运行。 平均每分钟处理 500k 条记录。

我添加了 10 个并发,但性能仍然相同。 如何使用并发来提高性能?


spring:
  cloud:
    config:
    function:
      definition: RiskProcessor1
    stream:
      bindings:
        RiskProcessor1-in-0:
          destination: ******
          consumer:
            concurrency: 10
      kafka:
        streams:
          binder:
            brokers: kaas-int.nam.nsroot.net:9093
            functions:
              RiskProcessor1:
                applicationId: RiskProcessor1_development
            configuration:
              commit.interval.ms: 1000
              security.protocol: SSL
              default:
                deserialization:
                  exception:
                    handler: org.apache.kafka.streams.errors.LogAndContinueExceptionHandler
              schema:
                registry:
                  url: *****:9081
          default:
            consumer:
              keySerde: ****
              valueSerde: ****
            producer:
              keySerde: ****
              valueSerde: ****
apache-kafka spring-kafka apache-kafka-streams spring-cloud-stream
1个回答
0
投票

大纲:

  1. 找出您在何处达到了阈值:内存、CPU 或 IO。如果存在阈值违规检查选项,可以通过升级硬件来克服它。
  2. 查找您的硬件可以支持的线程数。如果超出硬件的能力,则增加线程是没有意义的。

由于您有 20 个分区,因此最多可以有 20 个并发消费者。

Kafka 以批量方式传输数据,请检查您的批量大小,增加批量大小可能会帮助您提高性能。如果您使用适当的序列化(例如 Protocol buffers 或 Avro),高数据流量的性能将会更高。

© www.soinside.com 2019 - 2024. All rights reserved.