壓測寫入消息
./kafka-producer-perf-test.sh --topic test_perf --num-records 1000000 --record-size 1000 --throughput 20000 --producer-props bootstrap.servers=localhost:9092
88126 records sent, 17625.2 records/sec (16.81 MB/sec), 968.5 ms avg latency, 1409.0 max latency.
113096 records sent, 22587.6 records/sec (21.54 MB/sec), 249.2 ms avg latency, 681.0 max latency.
63205 records sent, 12615.8 records/sec (12.03 MB/sec), 1200.1 ms avg latency, 2560.0 max latency.
137255 records sent, 27451.0 records/sec (26.18 MB/sec), 381.6 ms avg latency, 902.0 max latency.
100020 records sent, 20000.0 records/sec (19.07 MB/sec), 4.2 ms avg latency, 142.0 max latency.
100020 records sent, 20004.0 records/sec (19.08 MB/sec), 1.1 ms avg latency, 18.0 max latency.
29195 records sent, 5839.0 records/sec (5.57 MB/sec), 1365.7 ms avg latency, 3544.0 max latency.
22680 records sent, 4528.8 records/sec (4.32 MB/sec), 5279.9 ms avg latency, 6772.0 max latency.
81390 records sent, 16100.9 records/sec (15.36 MB/sec), 3051.3 ms avg latency, 7415.0 max latency.
139410 records sent, 27693.7 records/sec (26.41 MB/sec), 1115.1 ms avg latency, 1637.0 max latency.
118290 records sent, 23610.8 records/sec (22.52 MB/sec), 1226.4 ms avg latency, 1804.0 max latency.
1000000 records sent, 17737.415304 records/sec (16.92 MB/sec), 962.23 ms avg latency, 7415.00 ms max latency, 831 ms 50th, 3932 ms 95th, 6894 ms 99th, 7285 ms 99.9th.
kafka-producer-perf-test.sh 腳本命令的參數(shù)為:
--topic topic名稱,本例為test_perf
--num-records 總共需要發(fā)送的消息數(shù),本例為1000000
--record-size 每個記錄的字節(jié)數(shù),本例為1000
--throughput 每秒鐘發(fā)送的記錄數(shù),本例為20000
--producer-props bootstrap.servers=localhost:9092 發(fā)送端的配置信息,本例只指定了kafka的鏈接信息
可以看到本例中,每秒平均向kafka寫入了16.92 MB的數(shù)據(jù),大概是17737條消息,每次寫入的平均延遲為962.23毫秒,最大的延遲為7415.00毫秒,831 ms內(nèi)占50%
壓測消費消息
[root@kafka bin]# ./kafka-consumer-perf-test.sh --zookeeper localhost:2181 --topic test_perf --fetch-size 1048576 --messages 1000000 --threads 1
start.time, end.time, data.consumed.in.MB, MB.sec, data.consumed.in.nMsg, nMsg.sec
2016-12-24 09:18:26:409, 2016-12-24 09:18:36:231, 553.8979, 56.3936, 580804, 59132.9668
kafka-consumer-perf-test.sh 腳本命令的參數(shù)為:
--zookeeper 指定zookeeper的鏈接信息,本例為localhost:2181 ,如果使用新的純java客戶端則使用另外的配置
--topic 指定topic的名稱,本例為test_perf
--fetch-size 指定每次fetch的數(shù)據(jù)的大小,本例為1048576,也就是1M
--messages 總共要消費的消息個數(shù),本例為1000000,100w
可以看到本例中,總共消費了553.8979M的數(shù)據(jù),每秒為56.3936, 總共消費了580804條消息,每秒為59132.9668
大家在壓測的時候肯定不會讓壓測腳本和kafka服務器跑在同一臺電腦上,比較壓測腳本也要占用很多服務器資源,影響壓測準確性。如果沒有多余的服務器,也可以這樣簡單的執(zhí)行以下,了解kafka在你給定的硬件上的一個大概的吞吐量,本文由
整理,轉(zhuǎn)載請注明出處。
|