进入容器
kubectl exec -it my-release-kafka-0 bash
进入 Kafka 脚本目录
cd /opt/bitnami/kafka/bin/
创建 Topic
./kafka-topics.sh --bootstrap-server localhost:9092 --create --topic test_producer_perf --partitions 6 --replication-factor 1
测试发送消息
测试条件为:1000W 消息总数,每条消息大小为1KB,每秒发送消息15000条。
./kafka-producer-perf-test.sh --num-records 10000000 --record-size 1000 --topic test_producer_perf --throughput 15000 --producer-props bootstrap.servers=localhost:9092
测试结果:
75015 records sent, 15000.0 records/sec (14.31 MB/sec), 7.0 ms avg latency, 118.0 ms max latency.
...
76125 records sent, 15222.0 records/sec (14.52 MB/sec), 11.1 ms avg latency, 199.0 ms max latency.
10000000 records sent, 14999.812502 records/sec (14.30 MB/sec), 13.19 ms avg latency, 1277.00 ms max latency, 0 ms 50th, 81 ms 95th, 179 ms 99th, 1084 ms 99.9th.
测试消费消息
测试条件为:消费500条消息,10个线程
./kafka-consumer-perf-test.sh --bootstrap-server localhost:9092 --messages 500 --topic test_producer_perf --threads 10
测试结果:
start.time, end.time, data.consumed.in.MB, MB.sec, data.consumed.in.nMsg, nMsg.sec, rebalance.time.ms, fetch.time.ms, fetch.MB.sec, fetch.nMsg.sec
2020-12-21 07:08:32:956, 2020-12-21 07:08:33:789, 1.4305, 1.7173, 500, 600.2401, 1608534513604, -1608534512771, -0.0000, -0.0000