# 新建并编辑文件
[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)
NodeJS——HTTP性能测试
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 此次性能测试开始时一头雾水,redis听说过、会拼写,仅限于此。 从安装到怎么写数据、怎么查数据、看配置,再到打压...
- 我的机器上有两块存储一块是固态硬盘一块是机械硬盘,为了更好的反映实际的使用环境,程序运行选择的是使用机械硬盘。操作...