Kafka壓力測試
測試腳本
kafka-producer-perf-test.sh --topic test-1 --num-records 100000 --record-size 1000 --throughput 2000 --producer-props bootstrap.servers=192.168.21.100:9092,192.168.21.101:9092,192.168.21.102:9092
參數(shù)解析:
--topic topic名稱娩怎,本例為test-1
--num-records 總共需要發(fā)送的消息數(shù)看蚜,本例為100000
--record-size 每個記錄的字節(jié)數(shù),本例為1000
--throughput 吞吐量即每秒鐘發(fā)送的記錄數(shù),本例為2000涣达,內(nèi)存大可以設(shè)置大點(diǎn)
--producer-props bootstrap.servers= 192.168.21.100:9092,192.168.21.101:9092,192.168.21.102:9092
生產(chǎn)寫入測試
bin/kafka-producer-perf-test.sh --topic test-1 --num-records 100000 --record-size 1000 --throughput 2000 --producer-props bootstrap.servers=192.168.21.100:9092,192.168.21.101:9092,192.168.21.102:9092
測試結(jié)果
發(fā)送100000條記錄,1266.849093條記錄/秒(1.21 MB/秒)证薇,平均17894.55 ms延遲度苔,最大33725.00 ms延遲,第50位13539 ms浑度,第95位32643 ms寇窑,第99位33074 ms
消費(fèi)測試
bin/kafka-consumer-perf-test.sh --broker-list 192.168.21.100:9092,192.168.21.101:9092,192.168.21.102:9092 --topic test-1 --fetch-size 1048576 --messages 100000 --threads 1 --timeout 100000
測試結(jié)果
耗時16s,總消費(fèi)95.7689MB箩张,平均每秒消費(fèi)5.8399MB/s甩骏,總消費(fèi)100421條,平均每秒消費(fèi)6123.6051條