Lua 与php 性能测试说明文档
测试环境 192.168.10.30
获取同一物品信息 读取redis localhost:6379
Php+nginx+redis
Lua+nginx+redis
ngx_lua将lua嵌入到nginx,让nginx执行lua脚本,高并发,非阻塞的处理各种请求。
url请求nginx服务器,然后lua查询redis,返回json数据。
基于 ngx_openresty/1.0.11.28
说明:经测试,lua 为php的5倍速度以上,并发处理能力好,并发上1000后失败的比较多,可能和服务器配置相关。并发越高,请求数量越大,lua性能体现越明显~
100并发
50000请求
总耗时
Time per request:
Time per request:
Transfer rate:
Long request
php
30.192 seconds
1656.09 [#/sec] (mean)
Time per request: 60.383 [ms] (mean)
0.604 [ms] (mean, across all concurrent requests)
141 (longest request)
lua
6.147 seconds
8134.12 [#/sec] (mean)
Time per request: 12.294 [ms] (mean)
0.123 [ms] (mean, across all concurrent requests)
23 (longest request)
500并发
10000请求
总耗时
Time per request:
Time per request:
Transfer rate:
Long request
php
7.098 seconds
1408.81 [#/sec] (mean)
354.910 [ms] (mean)
0.710 [ms] (mean, across all concurrent requests)
7078 (longest request)
lua
1.702 seconds
5876.22 [#/sec] (mean)
85.089 [ms] (mean)
0.170 [ms] (mean, across all concurrent requests)
1633 (longest request)
1000并发
50000请求
总耗时
Time per request:
Time per request:
Transfer rate:
Long request
php
51.890 seconds
(741 失败)
963.57 [#/sec] (mean)
1037.809 [ms] (mean)
1.038 [ms] (mean, across all concurrent requests)
44859 (longest request)
lua
7.337 seconds
( 49301 失败)
6815.02 [#/sec]
146.735 [ms] (mean)
0.147 [ms] (mean, across all concurrent requests)
7071 (longest request)
Php 100并发
ab -c 100 -n 50000 "http://192.168.10.30/jjserver/jjtool/src/get\_ware\_dict.php?wareid=2069&waretype=1&id=357"
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 192.168.10.30 (be patient)
Server Software: nginx
Server Hostname: 192.168.10.30
Server Port: 80
Document Path: /jjserver/jjtool/src/get_ware_dict.php?wareid=2069&waretype=1&id=357
Document Length: 455 bytes
Concurrency Level: 100
Time taken for tests: 30.192 seconds
Complete requests: 50000
Failed requests: 0
Write errors: 0
Total transferred: 29800000 bytes
HTML transferred: 22750000 bytes
Requests per second: 1656.09 [#/sec] (mean)
Time per request: 60.383 [ms] (mean)
Time per request: 0.604 [ms] (mean, across all concurrent requests)
Transfer rate: 963.90 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 5
Processing: 8 60 6.0 59 141
Waiting: 8 60 6.0 59 141
Total: 13 60 6.0 59 141
Percentage of the requests served within a certain time (ms)
50% 59
66% 60
75% 60
80% 60
90% 62
95% 68
98% 80
99% 89
100% 141 (longest request)
Lua 100并发
ab -c 100 -n 50000 "http://localhost:85/get\_ware\_dict?wareid=2069&waretype=&id"
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/
Server Software: ngx_openresty/1.0.11.28
Server Hostname: localhost
Server Port: 85
Document Path: /get_ware_dict?wareid=2069&waretype=&id
Document Length: 456 bytes
Concurrency Level: 100
Time taken for tests: 6.147 seconds
Complete requests: 50000
Failed requests: 0
Write errors: 0
Total transferred: 31250000 bytes
HTML transferred: 22800000 bytes
Requests per second: 8134.12 [#/sec] (mean)
Time per request: 12.294 [ms] (mean)
Time per request: 0.123 [ms] (mean, across all concurrent requests)
Transfer rate: 4964.67 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 7
Processing: 2 12 1.1 12 23
Waiting: 1 12 1.1 12 23
Total: 5 12 1.1 12 23
Percentage of the requests served within a certain time (ms)
50% 12
66% 12
75% 12
80% 12
90% 13
95% 14
98% 16
99% 17
100% 23 (longest request)
Php500 并发
ab -c 500 -n 10000 "http://192.168.10.30/jjserver/jjtool/src/get\_ware\_dict.php?wareid=2069&waretype=1&id=357"
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 192.168.10.30 (be patient)
Server Software: nginx
Server Hostname: 192.168.10.30
Server Port: 80
Document Path: /jjserver/jjtool/src/get_ware_dict.php?wareid=2069&waretype=1&id=357
Document Length: 455 bytes
Concurrency Level: 500
Time taken for tests: 7.098 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 5960000 bytes
HTML transferred: 4550000 bytes
Requests per second: 1408.81 [#/sec] (mean)
Time per request: 354.910 [ms] (mean)
Time per request: 0.710 [ms] (mean, across all concurrent requests)
Transfer rate: 819.97 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 25 153.6 0 1021
Processing: 2 292 653.1 113 7070
Waiting: 2 292 653.1 113 7070
Total: 7 317 672.3 114 7078
Percentage of the requests served within a certain time (ms)
50% 114
66% 125
75% 134
80% 143
90% 1087
95% 1148
98% 3122
99% 3216
100% 7078 (longest request)
lua500并发
ab -c 500 -n 10000 "http://localhost:85/get\_ware\_dict?wareid=2069&waretype=&id"
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 localhost (be patient)
Server Software: ngx_openresty/1.0.11.28
Server Hostname: localhost
Server Port: 85
Document Path: /get_ware_dict?wareid=2069&waretype=&id
Document Length: 456 bytes
Concurrency Level: 500
Time taken for tests: 1.702 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 6250000 bytes
HTML transferred: 4560000 bytes
Requests per second: 5876.22 [#/sec] (mean)
Time per request: 85.089 [ms] (mean)
Time per request: 0.170 [ms] (mean, across all concurrent requests)
Transfer rate: 3586.56 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 35 181.4 0 1000
Processing: 3 30 77.2 16 633
Waiting: 3 30 77.2 16 633
Total: 5 64 249.9 16 1633
Percentage of the requests served within a certain time (ms)
50% 16
66% 16
75% 16
80% 16
90% 21
95% 55
98% 1223
99% 1624
100% 1633 (longest request)
Lua500 并发
Php 1000并发
ab -c 1000 -n 50000 "http://192.168.10.30/jjserver/jjtool/src/get\_ware\_dict.php?wareid=2069&waretype=1&id=357"
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 192.168.10.30 (be patient)
Server Software: nginx
Server Hostname: 192.168.10.30
Server Port: 80
Document Path: /jjserver/jjtool/src/get_ware_dict.php?wareid=2069&waretype=1&id=357
Document Length: 455 bytes
Concurrency Level: 1000
Time taken for tests: 51.890 seconds
Complete requests: 50000
Failed requests: 741
(Connect: 0, Receive: 0, Length: 741, Exceptions: 0)
Write errors: 0
Non-2xx responses: 741
Total transferred: 29880028 bytes
HTML transferred: 22810762 bytes
Requests per second: 963.57 [#/sec] (mean)
Time per request: 1037.809 [ms] (mean)
Time per request: 1.038 [ms] (mean, across all concurrent requests)
Transfer rate: 562.33 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 6 72.2 0 1005
Processing: 14 713 2783.3 83 44841
Waiting: 14 713 2783.2 83 44841
Total: 44 719 2785.6 83 44859
Percentage of the requests served within a certain time (ms)
50% 83
66% 96
75% 113
80% 138
90% 1084
95% 3134
98% 7831
99% 14639
100% 44859 (longest request)
Lua 1000 并发
ab -c 1000 -n 50000 "http://localhost:85/get\_ware\_dict?wareid=2069&waretype=&id"
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/
Server Software: ngx_openresty/1.0.11.28
Server Hostname: localhost
Server Port: 85
Document Path: /get_ware_dict?wareid=2069&waretype=&id
Document Length: 67 bytes
Concurrency Level: 1000
Time taken for tests: 7.337 seconds
Complete requests: 50000
Failed requests: 49301
(Connect: 0, Receive: 0, Length: 49301, Exceptions: 0)
Write errors: 0
Total transferred: 30977390 bytes
HTML transferred: 22528089 bytes
Requests per second: 6815.02 [#/sec] (mean)
Time per request: 146.735 [ms] (mean)
Time per request: 0.147 [ms] (mean, across all concurrent requests)
Transfer rate: 4123.27 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 61 312.8 0 7000
Processing: 0 40 222.6 18 4723
Waiting: 0 40 222.6 18 4723
Total: 13 101 439.6 18 7071
Percentage of the requests served within a certain time (ms)
50% 18
66% 18
75% 19
80% 19
90% 22
95% 999
98% 1019
99% 2454
100% 7071 (longest request)