Comments (6)
顺便压测了下还没发布的webman
[vagrant@bogon /]$ wrk -c 100 -d 10s -t 10 --latency http://localhost:8787/webman/test
Running 10s test @ http://localhost:8787/webman/test
10 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 64.29ms 36.21ms 853.44ms 92.62%
Req/Sec 146.47 54.23 585.00 83.87%
Latency Distribution
50% 66.65ms
75% 70.34ms
90% 72.59ms
99% 92.12ms
14375 requests in 10.09s, 226.46MB read
Socket errors: connect 0, read 0, write 0, timeout 52
Requests/sec: 1424.21
Transfer/sec: 22.44MB
from mix.
@peinhu 我觉得需要贴一下 db 调用那部分的代码,我才能观察到问题的本质,我自己先尝试对比测试一下 2.1 vs 2.2
from mix.
2.1.9版本db调用代码
public function getAll()
{
$db = $this->pool->getConnection();
$sql = "SELECT * FROM `band_data` WHERE 1=1 limit 100";
$rows = $db->prepare($sql)->queryAll();
$db->release();
return $rows;
}
2.2.5版本db调用代码
public function getAll()
{
$db = context()->get('database');
$sql = "SELECT * FROM `band_data` WHERE 1=1 limit 100";
$rows = $db->prepare($sql)->queryAll();
//有release会报错,我就去掉了,我看手册上也没release了
return $rows;
}
是不是swoole的原因?因为我压测了下hyperf最新版,大概也就每秒800多。
from mix.
@peinhu 根据我 mac pro 的本机测试,v2.2 vs v2.1 数据库查询性能是非常接近的
- Mix v2.1.15
代码
/**
* Index
* @param ServerRequest $request
* @param Response $response
* @return Response
*/
public function index(ServerRequest $request, Response $response)
{
/** @var ConnectionPool $dbPool */
$dbPool = context()->get('dbPool');
$db = $dbPool->getConnection();
$result = $db->table('users')->limit(10)->get();
$db->release(); // 不手动释放的连接不会归还连接池,会在析构时丢弃
$content = json_encode($result);
return ResponseHelper::html($response, $content);
}
测试
MacBookPro:mix liujian$ wrk -c 100 -d 10s -t 10 --latency http://127.0.0.1:9501/
Running 10s test @ http://127.0.0.1:9501/
10 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 160.18ms 39.78ms 612.30ms 74.04%
Req/Sec 62.15 16.02 101.00 66.87%
Latency Distribution
50% 155.13ms
75% 180.72ms
90% 208.51ms
99% 280.88ms
6246 requests in 10.09s, 2.92MB read
Requests/sec: 618.74
Transfer/sec: 296.68KB
- Mix v2.2.5
代码
/**
* Index
* @param ServerRequest $request
* @param Response $response
* @return Response
*/
public function index(ServerRequest $request, Response $response)
{
/**
* @var Database $db
*/
$db = context()->get('database');
$result = $db->table('users')->limit(10)->get();
$content = json_encode($result);
return ResponseHelper::html($response, $content);
}
开启访问日志
Mix V2.2 默认开启了每个请求的访问日志,可以在 manifest/beans/event.php 移除 HttpServerListener::class 关闭
MacBookPro:mix liujian$ wrk -c 100 -d 10s -t 10 --latency http://127.0.0.1:9501/
Running 10s test @ http://127.0.0.1:9501/
10 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 181.90ms 70.54ms 1.26s 84.68%
Req/Sec 55.31 16.25 108.00 74.70%
Latency Distribution
50% 169.65ms
75% 205.41ms
90% 249.20ms
99% 423.80ms
5561 requests in 10.08s, 2.60MB read
Requests/sec: 551.60
Transfer/sec: 264.49KB
关闭访问日志
MacBookPro:mix liujian$ wrk -c 100 -d 10s -t 10 --latency http://127.0.0.1:9501/
Running 10s test @ http://127.0.0.1:9501/
10 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 154.97ms 65.09ms 1.80s 88.08%
Req/Sec 65.25 17.05 141.00 76.23%
Latency Distribution
50% 146.41ms
75% 175.41ms
90% 207.79ms
99% 346.81ms
6546 requests in 10.09s, 3.07MB read
Requests/sec: 648.48
Transfer/sec: 310.94KB
from mix.
是不是2.1.9版本有问题?延迟低得吓人,性能也很高,但是压测过一次或者两次以后,从网页就无法访问那个接口了,一直在转没返回。现在的2.2.5版本性能没那么高,但是没这个问题,压测完还是可以正常访问。
from mix.
@peinhu 和这个没关系,v2.2 基本上都是从 v2.1 继承过来的,改变都是微调,应该是 v2.2 默认开启了访问日志(写文件),这个降低了一些性能。
from mix.
Related Issues (20)
- Redis-subscribe 支持 prefix 否? HOT 1
- 没有对mysql保留关键字做反引号处理 HOT 1
- 2.2版本 UDP服务器会重复执行处理接收到的数据 HOT 2
- 官网无法访问 HOT 2
- 数据量较多时,json_decode可能会失败 HOT 7
- PDO执行使用问号占位符的原生SQL报错 HOT 2
- 建议项目遵从语义化版本来维护版本号 HOT 1
- PHP用ip curl post请求 会卡1秒 HOT 5
- table方法传入表名order报错 HOT 1
- 验证器场景设置optional未生效 HOT 3
- Coroutine中同时使用Channel和Database pool导致出错 HOT 5
- mix-skeleton使用context()->get('guzzle') 报错 HOT 1
- php8RC3-swoole4.5.6 运行出错 HOT 1
- or and 查找抛出异常 HOT 1
- Upgrade to Zipkin 2.0 HOT 1
- log组件报错 HOT 1
- 推送模式卡死 HOT 1
- 如何正确的提交 PR
- V3 启动事务后 lastInsertId 值不正确 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mix.