springnodejs 与 express 压力测试
发布于 10个月前 作者 solqkwgkwg 1099 次浏览

端口 8888 是 springnodejs 端口 3000 是 express

第一次压 springnodejs

Server Hostname:        127.0.0.1
Server Port:            8888

Document Path:          /ws/test
Document Length:        20 bytes

Concurrency Level:      100
Time taken for tests:   22.406 seconds
Complete requests:      20000
Failed requests:        0
Write errors:           0
Total transferred:      2700000 bytes
HTML transferred:       400000 bytes
Requests per second:    892.61 [#/sec] (mean)
Time per request:       112.031 [ms] (mean)
Time per request:       1.120 [ms] (mean, across all concurrent requests)
Transfer rate:          117.68 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.1      0      16
Processing:    16  112   9.2    109     234
Waiting:       16   76   8.6     78     188
Total:         16  112   9.2    109     234

Percentage of the requests served within a certain time (ms)
  50%    109
  66%    109
  75%    109
  80%    109
  90%    125
  95%    125
  98%    125
  99%    125
 100%    234 (longest request)

第一次压 expressjs

Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /test
Document Length:        25 bytes

Concurrency Level:      100
Time taken for tests:   5.953 seconds
Complete requests:      20000
Failed requests:        0
Write errors:           0
Total transferred:      4200000 bytes
HTML transferred:       500000 bytes
Requests per second:    3359.58 [#/sec] (mean)
Time per request:       29.766 [ms] (mean)
Time per request:       0.298 [ms] (mean, across all concurrent requests)
Transfer rate:          688.98 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.1      0      16
Processing:    16   30   6.3     31      63
Waiting:       16   20   7.1     16      47
Total:         16   30   6.3     31      63

Percentage of the requests served within a certain time (ms)
  50%     31
  66%     31
  75%     31
  80%     31
  90%     31
  95%     31
  98%     47
  99%     47
 100%     63 (longest request)

第二次压 expressjs

Server Software:
Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /test
Document Length:        25 bytes

Concurrency Level:      100
Time taken for tests:   6.563 seconds
Complete requests:      20000
Failed requests:        0
Write errors:           0
Total transferred:      4200000 bytes
HTML transferred:       500000 bytes
Requests per second:    3047.62 [#/sec] (mean)
Time per request:       32.813 [ms] (mean)
Time per request:       0.328 [ms] (mean, across all concurrent requests)
Transfer rate:          625.00 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.0      0      16
Processing:    16   33  35.8     31     531
Waiting:       16   22  30.1     16     531
Total:         16   33  35.8     31     531

Percentage of the requests served within a certain time (ms)
  50%     31
  66%     31
  75%     31
  80%     31
  90%     31
  95%     31
  98%     47
  99%     47
 100%    531 (longest request)

以下我关闭了 debug 调试信息 springnodejs

Server Software:
Server Hostname:        127.0.0.1
Server Port:            8888

Document Path:          /ws/test
Document Length:        20 bytes

Concurrency Level:      100
Time taken for tests:   5.875 seconds
Complete requests:      20000
Failed requests:        0
Write errors:           0
Total transferred:      2700000 bytes
HTML transferred:       400000 bytes
Requests per second:    3404.26 [#/sec] (mean)
Time per request:       29.375 [ms] (mean)
Time per request:       0.294 [ms] (mean, across all concurrent requests)
Transfer rate:          448.80 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.1      0      16
Processing:     0   29   6.7     31      78
Waiting:        0   20   7.0     16      47
Total:          0   29   6.6     31      78

Percentage of the requests served within a certain time (ms)
  50%     31
  66%     31
  75%     31
  80%     31
  90%     31
  95%     31
  98%     47
  99%     47
 100%     78 (longest request)

再压一次 springnodejs

Server Hostname:        127.0.0.1
Server Port:            8888

Document Path:          /ws/test
Document Length:        20 bytes

Concurrency Level:      100
Time taken for tests:   5.734 seconds
Complete requests:      20000
Failed requests:        0
Write errors:           0
Total transferred:      2700000 bytes
HTML transferred:       400000 bytes
Requests per second:    3487.74 [#/sec] (mean)
Time per request:       28.672 [ms] (mean)
Time per request:       0.287 [ms] (mean, across all concurrent requests)
Transfer rate:          459.81 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.1      0      16
Processing:     0   29   6.5     31      47
Waiting:        0   19   6.7     16      31
Total:          0   29   6.5     31      47

Percentage of the requests served within a certain time (ms)
  50%     31
  66%     31
  75%     31
  80%     31
  90%     31
  95%     31
  98%     31
  99%     47
 100%     47 (longest request)

测试代码

var express = require('express');
var app = express();

app.get('/test', function(req, res){
  res.send({'key':'hello rest'});
});

app.listen(3000);

springnodejs

example.springnodejs.com

module.exports = {
    'get:/test':{
        controller : function(){                        
            return {'key':'hello rest'};            
        }
    }
};

下面来大数据压力测试

module.exports = {
    cache : {},
    awake : function(){
        for(var i = 0 ;i < 5000000 ; i++){
            this.cache[i] = i;
        }
    },

    'get:/test':{
        controller : function(){                        
            return this.cache;          
        }
    }
};
var express = require('express');
var app = express();
var cache={};
for(var i = 0 ;i < 5000000 ; i++){
    cache[i] = i;
}
app.get('/test', function(req, res){
  res.send( cache);
});

app.listen(3000);

结果怎样?一起死掉

下面是压10W条记录

第一次 expressjs

Server Software:
Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /test
Document Length:        1777782 bytes

Concurrency Level:      100
Time taken for tests:   132.000 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1777972000 bytes
HTML transferred:       1777782000 bytes
Requests per second:    7.58 [#/sec] (mean)
Time per request:       13200.000 [ms] (mean)
Time per request:       132.000 [ms] (mean, across all concurrent requests)
Transfer rate:          13153.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.9      0      16
Processing:   906 12899 1585.2  13203   17375
Waiting:      125 8761 1412.6   8969   13125
Total:        906 12899 1585.2  13203   17375

Percentage of the requests served within a certain time (ms)
  50%  13203
  66%  13234
  75%  13250
  80%  13266
  90%  13328
  95%  13375
  98%  15422
  99%  16313
 100%  17375 (longest request)

第二次 expressjs


Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /test
Document Length:        1777782 bytes

Concurrency Level:      100
Time taken for tests:   133.109 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1777972000 bytes
HTML transferred:       1777782000 bytes
Requests per second:    7.51 [#/sec] (mean)
Time per request:       13310.938 [ms] (mean)
Time per request:       133.109 [ms] (mean, across all concurrent requests)
Transfer rate:          13044.17 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.4      0      16
Processing:   266 13013 1572.1  13203   17313
Waiting:      125 8830 1431.2   8969   13109
Total:        266 13013 1572.1  13203   17313

Percentage of the requests served within a certain time (ms)
  50%  13203
  66%  13281
  75%  13484
  80%  13531
  90%  13953
  95%  14109
  98%  15063
  99%  16391
 100%  17313 (longest request)

第一次 springnodejs

Server Hostname:        127.0.0.1
Server Port:            8888

Document Path:          /ws/test
Document Length:        1377781 bytes

Concurrency Level:      100
Time taken for tests:   76.906 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1377896000 bytes
HTML transferred:       1377781000 bytes
Requests per second:    13.00 [#/sec] (mean)
Time per request:       7690.625 [ms] (mean)
Time per request:       76.906 [ms] (mean, across all concurrent requests)
Transfer rate:          17496.65 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.4      0      16
Processing:   344 7518 922.7   7578    9984
Waiting:       94 5105 824.7   5141    7578
Total:        344 7518 922.6   7578    9984

Percentage of the requests served within a certain time (ms)
  50%   7578
  66%   7781
  75%   7859
  80%   7953
  90%   8031
  95%   8063
  98%   8859
  99%   9391
 100%   9984 (longest request)

第二次 springnodejs

Server Hostname:        127.0.0.1
Server Port:            8888

Document Path:          /ws/test
Document Length:        1377781 bytes

Concurrency Level:      100
Time taken for tests:   14.328 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1377896000 bytes
HTML transferred:       1377781000 bytes
Requests per second:    69.79 [#/sec] (mean)
Time per request:       1432.813 [ms] (mean)
Time per request:       14.328 [ms] (mean, across all concurrent requests)
Transfer rate:          93913.30 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.6      0      16
Processing:   -15 6621 2371.1   7547    9938
Waiting:        0 4659 1493.7   5141    7516
Total:          0 6621 2371.1   7547    9938

Percentage of the requests served within a certain time (ms)
  50%   7547
  66%   7563
  75%   7563
  80%   7563
  90%   7578
  95%   7594
  98%   8500
  99%   9250
 100%   9938 (longest request)

第三次 springnodejs

Server Hostname:        127.0.0.1
Server Port:            8888

Document Path:          /ws/test
Document Length:        1377781 bytes

Concurrency Level:      100
Time taken for tests:   86.844 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1377896000 bytes
HTML transferred:       1377781000 bytes
Requests per second:    11.51 [#/sec] (mean)
Time per request:       8684.375 [ms] (mean)
Time per request:       86.844 [ms] (mean, across all concurrent requests)
Transfer rate:          15494.51 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.1      0      16
Processing:   172 8486 1002.8   8688   11406
Waiting:       78 5758 924.5   5906    8641
Total:        172 8486 1002.8   8688   11406

Percentage of the requests served within a certain time (ms)
  50%   8688
  66%   8703
  75%   8703
  80%   8703
  90%   8719
  95%   8719
  98%   9938
  99%  10797
 100%  11406 (longest request)
/*相当于 LR 中的 每秒事务数 ,mean 表示这是一个平均值*/
Requests per second:    3.09 [#/sec] (mean)
/*相当于 LR 中的 平均事务响应时间,一次并发10个请求花费的时间 */
Time per request:       3234.651 [ms] (mean)
/*一次并发10个用户请求时的每个请求的平均响应时间*/
Time per request:       323.465 [ms] (mean, across all concurrent requests)
12 回复

大神 ,这个测试的结论是什么呢? 哪个更好

你是用什么工具测试的,如果要做并发测试 有什么好工具没

请问想表达什么意思?

结果来说就我写的好点,因为我写的 url 拦截是用 key 方式映射,肯定比express快。 就URL 拦截来说 设计不同吧,我认为一个URL操作对应用一个控制方法 就这是REST,他那个是中间件的概念,可以中转下一个中间件 还有他没有自动注入的概念,也没有拆分的概念,也没有程序预处理的概念,就拿URL 拦截来说,因为有程序预见处理概念,在程序启动时将准备数据的元数据先提取出来,程序执行期直接拿来当边界条件判断就行了,他如果没有的话,在执行时期还有算出边界处理,再进行运算。这当然是不先进的

主要是测试下内部其它封装性能如何,自己做的东西效果到底怎样 我没用过什么测试工具,也不太懂,就上面三个指标是比较重要的,凡是安装了 一根鸟毛,在bin目录都能找到

@solqkwgkwg ab -c 100 -n 20000 http://127.0.0.1:8888/ws/test ab -c 100 -n 20000 http://127.0.0.1:3000/test

ab 这种命令是什么工具的

@kissliux 凡是安装了 一根鸟毛,在bin目录都能找到

'get:/test’:除了controller还有什么属性? before,after ?

嘿嘿,可以无聊扩展,有兴趣研究的话 www.springnodejs.com

D:\APMServ5.2.6\Apache\bin>ab -c 100 -n 20000 http://127.0.0.1:82/test
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests

Test aborted after 10 failures

apr_socket_connect(): 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。   (730048)
Total of 7224 requests completed
D:\APMServ5.2.6\Apache\bin>ab -c 100 -n 20000 http://127.0.0.1:82/test
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests
Completed 8000 requests
Completed 10000 requests
Completed 12000 requests
Completed 14000 requests
Completed 16000 requests
Completed 18000 requests
Completed 20000 requests
Finished 20000 requests


Server Software:
Server Hostname:        127.0.0.1
Server Port:            82

Document Path:          /test
Document Length:        54 bytes

Concurrency Level:      100
Time taken for tests:   6.438 seconds
Complete requests:      20000
Failed requests:        0
Write errors:           0
Total transferred:      3720000 bytes
HTML transferred:       1080000 bytes
Requests per second:    3106.80 [#/sec] (mean)
Time per request:       32.188 [ms] (mean)
Time per request:       0.322 [ms] (mean, across all concurrent requests)
Transfer rate:          564.32 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.4      0      16
Processing:     0   32   7.6     31      63
Waiting:        0   31   7.7     31      63
Total:          0   32   7.6     31      63

Percentage of the requests served within a certain time (ms)
  50%     31
  66%     31
  75%     31
  80%     31
  90%     47
  95%     47
  98%     47
  99%     47
 100%     63 (longest request)
D:\APMServ5.2.6\Apache\bin>ab -c 100 -n 20000 http://127.0.0.1:82/test
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests
Completed 8000 requests
Completed 10000 requests
Completed 12000 requests
Completed 14000 requests
Completed 16000 requests
Completed 18000 requests
Completed 20000 requests
Finished 20000 requests


Server Software:
Server Hostname:        127.0.0.1
Server Port:            82

Document Path:          /test
Document Length:        54 bytes

Concurrency Level:      100
Time taken for tests:   6.313 seconds
Complete requests:      20000
Failed requests:        0
Write errors:           0
Total transferred:      3720000 bytes
HTML transferred:       1080000 bytes
Requests per second:    3168.32 [#/sec] (mean)
Time per request:       31.563 [ms] (mean)
Time per request:       0.316 [ms] (mean, across all concurrent requests)
Transfer rate:          575.50 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.3      0      16
Processing:     0   31   7.6     31      63
Waiting:        0   31   7.6     31      63
Total:          0   31   7.5     31      63

Percentage of the requests served within a certain time (ms)
  50%     31
  66%     31
  75%     31
  80%     31
  90%     47
  95%     47
  98%     47
  99%     47
 100%     63 (longest request)

我看了下代码,跟PHP MVC 一样。。。肯定慢了

太复杂了 又是this,又是that

回到顶部