zoukankan      html  css  js  c++  java
  • kafka 性能测试脚本

    【参考文章】:Kafka自带的性能测试脚本

    1. 生产消息压测脚本

    1.1 脚本及参数

      bin/kafka-producer-perf-test.sh  --topic kafka-test-0 --num-records 100--record-size 512 --throughput 100--producer-props bootstrap.servers=localhost:9092

      topic  :  topic名称 kafka-test-0

      num-records : 发送的消息总数 100

      record-size : 每个消息的大小 512byte

      throughput : 每秒最多发送消息数量 100

    1.2 执行结果

      100 records sent, 70.721358 records/sec (0.03 MB/sec), 214.93 ms avg latency, 1311.00 ms max latency, 216 ms 50th, 220 ms 95th, 1311 ms 99th, 1311 ms 99.9th.

      100 records sent : 发送了100条消息

      70.721358 records/sec (0.03 MB/sec) : 每秒钟平均发送 70.721358 条消息, 每秒钟发送了 0.03 MB 消息

      214.93 ms avg latency : 平局每条消息延迟 214.93 ms

      1311.00 ms max latency : 消息最大延迟为 1311.00 ms

    2. 消费消息压测脚本

      bin/kafka-consumer-perf-test.sh --broker-list localhost:9092 --topic  kafka-test-0 --fetch-size 1048576 --messages 10000 --threads 1 --timeout 10000

      broker-list localhost:9092 : kafka配置信息

      topic  :  topic名称 kafka-test-0

      fetch-size 1048576 : 每次fetch的数据的大小

      messages 10000 : 消费消息总数 10000

      threads 1 : 消费线程数

      timeout 10000 : 超时时间10S

    3. 批量测试脚本

    #!/bin/sh
    
    read -p "topic数量:" topicNum
    
    #read -p "消息总数:" msgNum
    
    #read -p "每秒发送消息数量:" secNum
    
    topicName="kafka-test-"
    
    tempNum=0
    
    timeout=`expr ${topicNum} / 10 * 10000`
    
    while(( ${topicNum}>${tempNum}))
    do
    
        realName="${topicName}${tempNum}"
    
        nohup /stpaas/kafka/bin/kafka-topics.sh --zookeeper localhost:2181  --partitions 1  --replication-factor 1 --create --topic ${realName} >"${topicNum}.txt" 2>&1 &
    
        nohup /stpaas/kafka/bin/kafka-producer-perf-test.sh --topic ${realName} --num-records 10000 --record-size 512 --throughput 5000 --producer-props bootstrap.servers=localhost:9092 >>"${topicNum}.txt" 2>&1  &
    
        nohup /stpaas/kafka/bin/kafka-consumer-perf-test.sh --broker-list localhost:9092 --topic ${realName} --fetch-size 1048576 --messages 10000 --threads 1 --timeout ${timeout} >>"${topicNum}.txt" 2>&1 &
    
        let tempNum=${tempNum}+1
    
    
    done
  • 相关阅读:
    Lucene in action 笔记 case study
    关于Restful Web Service的一些理解
    Lucene in action 笔记 analysis篇
    Lucene in action 笔记 index篇
    Lucene in action 笔记 term vector
    Lucene in action 笔记 search篇
    博客园开博记录
    数论(算法概述)
    DIV, IFRAME, Select, Span标签入门
    记一个较困难的SharePoint性能问题的分析和解决
  • 原文地址:https://www.cnblogs.com/virgosnail/p/11278542.html
Copyright © 2011-2022 走看看