NodeJS——HTTP性能测试

# 新建并编辑文件
[root@localhost http]# vi http.js

var http = require('http')
http
    .createServer(function(req,res){
        res.writeHead(200,{'Context-Type':'text/plain'})
        res.write('Hello NodeJS')
        res.end()
    })
    .listen(3000)

# 运行
[root@localhost http]# node http.js



# 启动服务后,新开一个窗口执行,如果没有此命令,执行yum install httpd-tools
[root@localhost ~]# ab -n1000 -c10 http://172.16.0.162:3000/
# 结果如下
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.16.0.162 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        
Server Hostname:        172.16.0.162
Server Port:            3000

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      10
Time taken for tests:   0.515 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      113000 bytes
HTML transferred:       12000 bytes
Requests per second:    1941.56 [#/sec] (mean)
Time per request:       5.151 [ms] (mean)
Time per request:       0.515 [ms] (mean, across all concurrent requests)
Transfer rate:          214.25 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       4
Processing:     1    5   4.5      3      34
Waiting:        1    5   4.4      3      34
Total:          2    5   4.5      4      34

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      5
  75%      6
  80%      6
  90%      8
  95%     11
  98%     23
  99%     31
 100%     34 (longest request)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 此次性能测试开始时一头雾水,redis听说过、会拼写,仅限于此。 从安装到怎么写数据、怎么查数据、看配置,再到打压...
    灼灼2015阅读 2,030评论 1 5
  • 我的机器上有两块存储一块是固态硬盘一块是机械硬盘,为了更好的反映实际的使用环境,程序运行选择的是使用机械硬盘。操作...
    FanChengSheng阅读 4,772评论 1 1
  • 日 期:2014-11-12 测试目的 测试页面的负载量 测试范围 express +ejs helloworl...
    流星狂飙阅读 12,129评论 3 7
  • 顶级专家,在大家的眼里应该是什么样的? 是不是应该像这样的,眉头紧锁,时刻忧国忧民的爱国范儿。。。 如果有一个专家...
    宫小傅阅读 987评论 0 0
  • 偶尔有写点什么的欲望,却没有找到合适的平台。 工作和家庭原因,在老妈家借住,没有wifi,工作忙乱,孩子尚小。哇,...
    赵妖镜Karen阅读 252评论 0 2