服务器:
阿里云ECS:1核1G内存,CentOS6.5 x64
返回内容:
{"ErrInfo":{"ErrCode":0,"ErrMsg":""},"Result":{"CurrentTime":"2015-10-06 09:46:26"}}
在直接用time.Now()返回时间,大约是4550qps,见:Web性能研究-ab压力测试
用从redis中请求返回结果:
[root@iZ23n2t9gynZ ~]# ab -n 200000 -c 200 http://127.0.0.1:9090/api/System.GetTime
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 20000 requests
Completed 40000 requests
Completed 60000 requests
Completed 80000 requests
Completed 100000 requests
Completed 120000 requests
Completed 140000 requests
Completed 160000 requests
Completed 180000 requests
Completed 200000 requests
Finished 200000 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 9090
Document Path: /api/System.GetTime
Document Length: 84 bytes
Concurrency Level: 200
Time taken for tests: 55.742 seconds
Complete requests: 200000
Failed requests: 1816
(Connect: 0, Receive: 0, Length: 1816, Exceptions: 0)
Write errors: 0
Total transferred: 40176392 bytes
HTML transferred: 16776392 bytes
Requests per second: 3587.96 [#/sec] (mean)
Time per request: 55.742 [ms] (mean)
Time per request: 0.279 [ms] (mean, across all concurrent requests)
Transfer rate: 703.86 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 18 161.9 0 7000
Processing: 0 37 13.2 37 2114
Waiting: 0 37 13.2 37 2114
Total: 1 55 162.8 37 7041
Percentage of the requests served within a certain time (ms)
50% 37
66% 38
75% 39
80% 39
90% 41
95% 43
98% 55
99% 1038
100% 7041 (longest request)
有疑问加站长微信联系(非本文作者)