node压力测试

压力测试

ab测试(ApacheBench);

  1. 介绍: 这是apache提供的压测工具;

  2. 使用:

    • 启动node服务;

    • 我用的XAMPP,进入bin文件夹,打开命令行,执行下面命令:

       // -n: 总请求数; -c: 一次产生的请求个数(并发数);
      ab -n 10000 -c 5 http://127.0.0.1:port/
    • 等待结果返回, 结果如下;
  3. 结果分析:

    Server Software:       
    Server Hostname: 127.0.0.1
    Server Port: 700

    Document Path: /
    Document Length: 43 bytes

    Concurrency Level(并发用户数,sequelize pool设置的max值): 5
    Time taken for tests(测试时间): 0.124 seconds
    Complete requests(请求数): 100
    Failed requests(失败请求数): 0
    Non-2xx responses(非2xx响应): 100
    Total transferred(总传输字节数): 19900 bytes
    HTML transferred(HTML传输数): 4300 bytes
    Requests per second(每秒请求): 807.97 [#/sec] (mean)
    Time per request(每次请求时长): 6.188 [ms] (mean)
    Time per request(每次请求时长/并发数): 1.238 [ms] (mean, across all concurrent requests)
    Transfer rate(传输速度): 157.02 [Kbytes/sec] received

    Connection Times(连接时间) (ms)
    min(最小) mean(均值)[+/-sd] median(中值) max(最大)
    Connect(连接): 0 0 0.1 0 0
    Processing(处理): 1 6 1.4 5 9
    Waiting(等待): 1 6 1.4 5 9
    Total: 2 6 1.4 5 10

    // 下面的内容为整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中 50% 的用户响应时间小于 6毫秒,60 % 的用户响应时间小于 7 毫秒,
    Percentage of the requests served within a certain time (ms)
    50% 6
    66% 7
    75% 8
    80% 9
    90% 10
    95% 13
    98% 17
    99% 21
    100% 114 (longest request)
  4. 更多扩展;

  5. 问题

    • 报错: apr_socket_recv: Connection reset by peer (54); 
      Answer: 设置的 -c的值超出了apache默认的最大并发数;查看或修改可以在xamppfiles/etc/extra/httpd-default.conf查看MaxKeepAliveRequests;
  6. 报告分析

报告分析我还没有头绪,想来如果请求数大,并发数大的情况下和请求数小,并发数小的情况下的每秒请求和每次请求保持大致一致,就问题不大;这方面有经验的望不吝赐教.

Jmeter(图形化工具);

 

POSTMAN(图形化工具);

目前个人更推荐使用postman进行接口模拟,以及各种针对接口的测试 

 

代码性能分析 

posted @ 2017-04-09 21:19  六石  阅读(1816)  评论(0编辑  收藏  举报