Lua 与php 性能测试说明文档

Stella981
• 阅读 605

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)

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Jacquelyn38 Jacquelyn38
2年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Wesley13 Wesley13
2年前
java将前端的json数组字符串转换为列表
记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
Wesley13 Wesley13
2年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
2年前
PHP创建多级树型结构
<!lang:php<?php$areaarray(array('id'1,'pid'0,'name''中国'),array('id'5,'pid'0,'name''美国'),array('id'2,'pid'1,'name''吉林'),array('id'4,'pid'2,'n
Stella981 Stella981
2年前
Bypass ngx_lua_waf SQL注入防御(多姿势)
0x00前言ngx\_lua\_waf是一款基于ngx\_lua的web应用防火墙,使用简单,高性能、轻量级。默认防御规则在wafconf目录中,摘录几条核心的SQL注入防御规则:select.(from|limit)(?:(union(.?)select))(?:from\Winformation_schema\W)这边
Wesley13 Wesley13
2年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Wesley13 Wesley13
2年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
2个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这