PHP7+Swoole、Node Express、Sails、Beego、ThinkPHP 并发性能测试

简介: 最近由于产品业务出现请求瓶颈,需要更换产品框架,针对现在集中主流方案进行了逐一测试  服务器硬件配置:2 核 2G虚拟机 , 10000请求 500并发测试结果如下性能测试结果1、Nodejs Express测试结果如下 大约每秒处理2100请求 响应时间在230ms左右,cpu负...

最近由于产品业务出现请求瓶颈,需要更换产品框架,针对现在集中主流方案进行了逐一测试  

服务器硬件配置:2 核 2G虚拟机 , 10000请求 500并发测试结果如下


性能测试结果

1、Nodejs Express测试结果如下 大约每秒处理2100请求 响应时间在230ms左右,cpu负载百分之40左右

Server Software:
Server Hostname:        172.16.200.202
Server Port:            3000

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      500
Time taken for tests:   4.692 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2060000 bytes
HTML transferred:       120000 bytes
Requests per second:    2131.47 [#/sec] (mean)
Time per request:       234.580 [ms] (mean)
Time per request:       0.469 [ms] (mean, across all concurrent requests)
Transfer rate:          428.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1   16   8.3     15      57
Processing:    71  212  31.0    204     359
Waiting:       71  211  31.0    203     359
Total:         86  228  29.0    221     380

Percentage of the requests served within a certain time (ms)
  50%    221
  66%    230
  75%    241
  80%    248
  90%    258
  95%    291
  98%    302
  99%    304
 100%    380 (longest request)


2、PHP7+Swoole 秒处理请求2300  响应时间40s左右 cpu只占用了15% 

Server Software:        12XueWeibo
Server Hostname:        172.16.200.202
Server Port:            3456

Document Path:          /
Document Length:        27 bytes

Concurrency Level:      100
Time taken for tests:   3.406 seconds
Complete requests:      8000
Failed requests:        0
Total transferred:      1584000 bytes
HTML transferred:       216000 bytes
Requests per second:    2348.89 [#/sec] (mean)
Time per request:       42.573 [ms] (mean)
Time per request:       0.426 [ms] (mean, across all concurrent requests)
Transfer rate:          454.18 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        4   18   2.9     19      28
Processing:    10   24   3.5     24      46
Waiting:       10   24   3.5     24      46
Total:         16   42   3.4     42      60

Percentage of the requests served within a certain time (ms)
  50%     42
  66%     44
  75%     44
  80%     45
  90%     46
  95%     48
  98%     49
  99%     51
 100%     60 (longest request)

3、Nodejs Sails  每秒处理500左右请求 每个请求响应用掉190ms 时间 cpu 百分之50左右


Benchmarking 172.16.200.202 (be patient)
Completed 800 requests
Completed 1600 requests
Completed 2400 requests
Completed 3200 requests
Completed 4000 requests
Completed 4800 requests
Completed 5600 requests
Completed 6400 requests
Completed 7200 requests
Completed 8000 requests
Finished 8000 requests


Server Software:
Server Hostname:        172.16.200.202
Server Port:            1337

Document Path:          /
Document Length:        10444 bytes

Concurrency Level:      100
Time taken for tests:   14.820 seconds
Complete requests:      8000
Failed requests:        0
Total transferred:      87740708 bytes
HTML transferred:       83552000 bytes
Requests per second:    539.81 [#/sec] (mean)
Time per request:       185.249 [ms] (mean)
Time per request:       1.852 [ms] (mean, across all concurrent requests)
Transfer rate:          5781.69 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        2   12  14.3     11    1231
Processing:    23  173  48.9    165     515
Waiting:       16  125  40.9    123     432
Total:         34  185  50.2    176    1313

Percentage of the requests served within a certain time (ms)
  50%    176
  66%    179
  75%    181
  80%    184
  90%    239
  95%    298
  98%    343
  99%    362
 100%   1313 (longest request)

4、golang Beego   每秒大约处理2400个请求  每个请求响应时间45ms  cpu 百分之15左右


Document Path:          /routerinfo
Document Length:        1152 bytes

Concurrency Level:      100
Time taken for tests:   3.494 seconds
Complete requests:      8000
Failed requests:        7641
   (Connect: 0, Receive: 0, Length: 7641, Exceptions: 0)
Total transferred:      10348153 bytes
HTML transferred:       9468153 bytes
Requests per second:    2289.46 [#/sec] (mean)
Time per request:       43.678 [ms] (mean)
Time per request:       0.437 [ms] (mean, across all concurrent requests)
Transfer rate:          2892.06 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        2   17   4.5     18      27
Processing:    11   26   8.0     24      85
Waiting:       11   26   8.0     24      85
Total:         15   43   6.9     42      96

Percentage of the requests served within a certain time (ms)
  50%     42
  66%     44
  75%     46
  80%     46
  90%     49
  95%     54
  98%     64
  99%     71
 100%     96 (longest request)


5、 ThinkPHP 请求量缩减10倍1000, 并发量缩减50倍10,结果如下 每秒106请求 平均响应时间 94ms ,目前api就是用的此框架 果断需要更换了

Server Software:        Tengine/2.1.2
Server Hostname:        api.uia.com
Server Port:            80

Document Path:          /index/index/index
Document Length:        622 bytes

Concurrency Level:      10
Time taken for tests:   9.405 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      960000 bytes
HTML transferred:       622000 bytes
Requests per second:    106.33 [#/sec] (mean)
Time per request:       94.047 [ms] (mean)
Time per request:       9.405 [ms] (mean, across all concurrent requests)
Transfer rate:          99.68 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    2   0.6      2       8
Processing:    32   92  14.5     91     170
Waiting:       32   92  14.4     91     170
Total:         33   94  14.5     93     172

Percentage of the requests served within a certain time (ms)
  50%     93
  66%     99
  75%    103
  80%    105
  90%    111
  95%    117
  98%    126
  99%    133
 100%    172 (longest request)




很显然从结果看来 Sails、ThinkPHP等 经过框架路由之后 损耗还是很严重的!! 







相关实践学习
通过性能测试PTS对云服务器ECS进行规格选择与性能压测
本文为您介绍如何利用性能测试PTS对云服务器ECS进行规格选择与性能压测。
目录
相关文章
|
1天前
|
JSON JavaScript 前端开发
❤Nodejs 第九章(token身份认证和express-jwt的安装认识)
【4月更文挑战第9天】Node.js第九章介绍了Token身份认证,特别是JWT(JSON Web Token)作为跨域认证的解决方案。JWT由Header、Payload和Signature三部分组成,用于在客户端和服务器间安全传输用户信息。前端收到JWT后存储在localStorage或sessionStorage中,并在请求头中发送。Express-JWT是一个中间件,用于解析JWT。基本用法包括设置secret和algorithms。注意安全问题,避免混合使用不同算法以防止降级攻击。
43 0
原生php实现列表接口+分页接口+排序接口组合使用+包括测试数据(不加任何封装)
原生php实现列表接口+分页接口+排序接口组合使用+包括测试数据(不加任何封装)
原生php实现列表接口+分页接口+排序接口组合使用+包括测试数据(不加任何封装)
|
1天前
|
JSON JavaScript 前端开发
超级实用!详解Node.js中的util模块和express模块
超级实用!详解Node.js中的util模块和express模块
|
1天前
|
存储 JavaScript 数据库
nodejs中express框架实现增删改查接口
nodejs中express框架实现增删改查接口
|
1天前
|
开发框架 JavaScript 中间件
node+express搭建服务器环境
node+express搭建服务器环境
node+express搭建服务器环境
|
1天前
|
监控 供应链 测试技术
PTS压测问题之自动变成500 并发如何解决
PTS(Performance Testing Service)是一项面向网站、应用等提供的压力测试服务,用于模拟不同场景下的用户访问,评估系统的性能表现;在进行PTS压测时,可能会出现一些异常或报错,本合集将PTS压测中频繁出现的问题及其解决办法进行汇编,旨在帮助用户更有效地进行性能测试和问题定位。
290 2
|
1天前
|
监控 测试技术 Apache
如何模拟100个并发用户进行压力测试?
通过以上步骤,你可以使用JMeter对应用程序进行压力测试,评估其性能表现。
|
1天前
|
开发框架 JavaScript 中间件
深入探索Node.js的Express框架:使用与中间件详解
【4月更文挑战第30天】本文深入探讨了Node.js的Express框架,介绍了其作为Web开发的强大工具,主要聚焦于基本使用和中间件。Express是基于Node.js的Web应用框架,用于构建高效的应用和API。文章详细讲解了如何安装Express,创建简单应用,以及中间件的工作原理和应用,包括中间件的顺序、错误处理和挂载位置。此外,还提到了使用第三方中间件扩展功能。理解Express基础和中间件对于开发高质量Web应用至关重要。
|
1天前
|
设计模式 前端开发 PHP
【PHP开发专栏】ThinkPHP框架实战开发
【4月更文挑战第29天】ThinkPHP是中国流行的PHP框架,以其轻量级、模块化和高安全性受到开发者欢迎。本文介绍了ThinkPHP的基础,包括MVC设计模式,以及核心组件如路由、数据库操作、表单处理、模板引擎和错误处理。通过一个博客系统示例,展示了如何进行项目开发,包括控制器、模型和视图的创建。使用ThinkPHP能有效提升开发效率,帮助开发者快速构建复杂的Web应用。