laravel octane和webman对比qps

环境版本

业务:双方都是随机从数据库用户表里面查询一条数据
中间件:无
php版本8.1.7
laravel版本:8.5
mysql版本:5.7(阿里云)
laravel容器和webman容器都在本地
进程数量:16
代理:本地nginx容器

电脑硬件

处理器 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz 2.00 GHz
机带 RAM 16.0 GB (15.9 GB 可用)

系统版本 Windows 11 专业版

版本 22H2
安装日期 ‎2022/‎5/‎21
操作系统版本 22621.290
体验 Windows Feature Experience Pack 1000.22632.1000.0

laravel 带数据库 ab -n 10000 -c 100

Server Software: nginx
Server Hostname: 172.19.0.15
Server Port: 80

Document Path: /api/index
Document Length: 243 bytes

Concurrency Level: 100
Time taken for tests: 35.480 seconds
Complete requests: 10000
Failed requests: 7758
(Connect: 0, Receive: 0, Length: 7758, Exceptions: 0)
Total transferred: 4611690 bytes
HTML transferred: 2731690 bytes
Requests per second: 281.85 [#/sec] (mean)
Time per request: 354.803 [ms] (mean)
Time per request: 3.548 [ms] (mean, across all concurrent requests)
Transfer rate: 126.93 [Kbytes/sec] received

laravel 不带数据库 ab -n 10000 -c 1000 -k

Benchmarking 172.19.0.15 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software: nginx
Server Hostname: 172.19.0.15
Server Port: 80

Document Path: /api/index
Document Length: 3 bytes

Concurrency Level: 1000
Time taken for tests: 13.950 seconds
Complete requests: 10000
Failed requests: 0
Keep-Alive requests: 0
Total transferred: 1990000 bytes
HTML transferred: 30000 bytes
Requests per second: 716.87 [#/sec] (mean)
Time per request: 1394.961 [ms] (mean)
Time per request: 1.395 [ms] (mean, across all concurrent requests)
Transfer rate: 139.31 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 5 15.2 0 73
Processing: 23 1292 599.9 1506 3437
Waiting: 16 1292 600.0 1505 3437
Total: 81 1297 595.2 1506 3469

Percentage of the requests served within a certain time (ms)
50% 1506
66% 1591
75% 1633
80% 1664
90% 1957
95% 2312
98% 2600
99% 2723
100% 3469 (longest request)

webman 带数据库 ab -n 10000 -c 100

Server Software: nginx
Server Hostname: 172.19.0.12
Server Port: 80

Document Path: /
Document Length: 322 bytes

Concurrency Level: 100
Time taken for tests: 34.694 seconds
Complete requests: 10000
Failed requests: 9697
(Connect: 0, Receive: 0, Length: 9697, Exceptions: 0)
Total transferred: 4138843 bytes
HTML transferred: 2638843 bytes
Requests per second: 288.23 [#/sec] (mean)
Time per request: 346.943 [ms] (mean)
Time per request: 3.469 [ms] (mean, across all concurrent requests)
Transfer rate: 116.50 [Kbytes/sec] received

webman 不带数据库 ab -n 10000 -c 1000 -k

Benchmarking 172.19.0.12 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software: nginx/1.21.6
Server Hostname: 172.19.0.12
Server Port: 80

Document Path: /
Document Length: 3 bytes

Concurrency Level: 1000
Time taken for tests: 0.257 seconds
Complete requests: 10000
Failed requests: 0
Keep-Alive requests: 10000
Total transferred: 1630000 bytes
HTML transferred: 30000 bytes
Requests per second: 38845.51 [#/sec] (mean)
Time per request: 25.743 [ms] (mean)
Time per request: 0.026 [ms] (mean, across all concurrent requests)
Transfer rate: 6183.42 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 4 12.8 0 62
Processing: 2 18 9.6 15 62
Waiting: 1 18 9.6 15 55
Total: 2 22 17.4 16 106

Percentage of the requests served within a certain time (ms)
50% 16
66% 23
75% 27
80% 29
90% 47
95% 65
98% 79
99% 84
100% 106 (longest request)

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 11

我简单测试了一下用我的苹果电脑:查询同一数据库同一表。都用ORM操作。

电脑苹果I10600 +32G(2020)
webman:不带数据查询:101843    带数据库:33726 
laravel:不带数据库:4859   带数据:4020   
基本上数据库没啥影响了,主要是laravel初使化占用了时间
上面测试主要是本机的数据库性能不错,如果换到生产环境,结果就变成以下情况了:
线上腾讯生产环境:2C4G  启用opcache  php8 mysql5.7
webman:不带数据查询:9500       带数据库:4598   (注如果不带orm等组件,webman在2c4G输出ok性能在42000左右)
swoole+laravel:不带数据库:715    带数据:  574
FPM+laravel: 不带数据库: 166      带数据:149

经测试webman还是有一定优势的,我现在对webman与laravel组合用更新,一般企业系统并不须要webman,如果系统带小程序商城类式高并发的,则把前端接口部分用webman来写提升性能,fpm那性在优化,高并发下cpu占用太高了,swoole+laravel在使用中容易502,性能也没有webman好,所以个人键议就部分小程序app须要高并发的在用webman写一下就行了,在webman中共享缓存与登陆信息与laravel同步,仅参考哈,

1年前 评论

都失败了很多哦,频率限制了

1年前 评论
LXK (楼主) 1年前

带数据库后,瓶颈就是数据库了

1年前 评论

建议可以加个带redis的测,都知道一般瓶颈在数据库那儿, 如果业务真正有并发需求,这个接口中用到的数据都会提前缓存,加个redis应该更能贴合实战场景

1年前 评论
LXK (楼主) 1年前
游离不2

加了数据库的压测毫无意义

1年前 评论
LXK (楼主) 1年前
游离不2 (作者) 1年前
meows 5个月前
meows 5个月前

我简单测试了一下用我的苹果电脑:查询同一数据库同一表。都用ORM操作。

电脑苹果I10600 +32G(2020)
webman:不带数据查询:101843    带数据库:33726 
laravel:不带数据库:4859   带数据:4020   
基本上数据库没啥影响了,主要是laravel初使化占用了时间
上面测试主要是本机的数据库性能不错,如果换到生产环境,结果就变成以下情况了:
线上腾讯生产环境:2C4G  启用opcache  php8 mysql5.7
webman:不带数据查询:9500       带数据库:4598   (注如果不带orm等组件,webman在2c4G输出ok性能在42000左右)
swoole+laravel:不带数据库:715    带数据:  574
FPM+laravel: 不带数据库: 166      带数据:149

经测试webman还是有一定优势的,我现在对webman与laravel组合用更新,一般企业系统并不须要webman,如果系统带小程序商城类式高并发的,则把前端接口部分用webman来写提升性能,fpm那性在优化,高并发下cpu占用太高了,swoole+laravel在使用中容易502,性能也没有webman好,所以个人键议就部分小程序app须要高并发的在用webman写一下就行了,在webman中共享缓存与登陆信息与laravel同步,仅参考哈,

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!