在 AWS 上的 Kubernetes 中运行 Kafka

在 AWS 上的 Kubernetes 中运行 Kafka

我有以下情况:

3 个节点实例分布在 3 个可用区域

  • 6 个 Broker 在 StatefulSets 中运行,并使用 AWS 外部卷来获取 Kafka 数据。
  • 实例大小:m4.2xlarge
  • EBS 卷:st1 - 500 GiB
  • 在 Kubernetes 资源级别没有设置限制请求和内存(不适合生产 - 必须设置资源限制)1 个主题,6 个分区,无复制。使用 librdkafka 和 Kafka 版本 0.11.0

生产者发送一条大小为 100 字节的消息

命令如下:

kubectl exec -it kafka-kafka-librdkafka -- examples/rdkafka_performance -P -t test -s 100 -b kafka-kafka-headless:9092 -X request.timeout.ms=900000 -X batch.num.messages=10000 -X queue.buffering.max.ms=1000

结果:

% Sending messages of size 100 bytes
% 500000 messages produced (50000000 bytes), 0 delivered (offset 0, 0 failed) in 1000ms: 0 msgs/s and 0.00 MB/s, 41 produce failures, 500000 in queue, no compression
% 1000000 messages produced (100000000 bytes), 500000 delivered (offset 0, 0 failed) in 2000ms: 249957 msgs/s and 25.00 MB/s, 65 produce failures, 500000 in queue, no compression
% 1525491 messages produced (152549100 bytes), 1025491 delivered (offset 0, 0 failed) in 3000ms: 341774 msgs/s and 34.18 MB/s, 90 produce failures, 500000 in queue, no compression
% 1958991 messages produced (195899100 bytes), 1525500 delivered (offset 0, 0 failed) in 4000ms: 381328 msgs/s and 38.13 MB/s, 120 produce failures, 433491 in queue, no compression
% 2232174 messages produced (223217400 bytes), 2028173 delivered (offset 0, 0 failed) in 5000ms: 405594 msgs/s and 40.56 MB/s, 150 produce failures, 204001 in queue, no compression
% 2622943 messages produced (262294300 bytes), 2528180 delivered (offset 0, 0 failed) in 6000ms: 421328 msgs/s and 42.13 MB/s, 161 produce failures, 94763 in queue, no compression
% 3145529 messages produced (314552900 bytes), 3035578 delivered (offset 0, 0 failed) in 7000ms: 433623 msgs/s and 43.36 MB/s, 176 produce failures, 109951 in queue, no compression
% 3675274 messages produced (367527400 bytes), 3498817 delivered (offset 0, 0 failed) in 8039ms: 435186 msgs/s and 43.52 MB/s, 196 produce failures, 176458 in queue, no compression
% 4181717 messages produced (418171700 bytes), 3961228 delivered (offset 0, 0 failed) in 9042ms: 438068 msgs/s and 43.81 MB/s, 213 produce failures, 220489 in queue, no compression
% 4669614 messages produced (466961400 bytes), 4499671 delivered (offset 0, 0 failed) in 10085ms: 446156 msgs/s and 44.62 MB/s, 230 produce failures, 169946 in queue, no compression
% 5071907 messages produced (507190700 bytes), 4964422 delivered (offset 0, 0 failed) in 11132ms: 445930 msgs/s and 44.59 MB/s, 230 produce failures, 107490 in queue, no compression
% 5638247 messages produced (563824700 bytes), 5392203 delivered (offset 0, 0 failed) in 12141ms: 444125 msgs/s and 44.41 MB/s, 231 produce failures, 246046 in queue, no compression

就我们现有的资源而言,我认为我们在某些方面受到了限制。您知道瓶颈可能在哪里吗?

答案1

我的工作中管理 3 个 kubernetes 集群和 4 个 kafka 集群(每个 3 个 kafka 节点)。

我永远不会把 kafka 放在 kubernetes 里面。这根本没有意义。

只需为 kafka 集群使用专用的 ec2 机器,并将 k8s VPC 与 kafka VPC 连接起来。

Kafka 是一个数据库,它从直接访问操作系统中受益匪浅,并且您可以比 k8s 部署更自由地对其进行调整。

K8s 不是万能的,使用它来服务和 cronjobs 并且把数据库放在外面。

相关内容