GithubHelp home page GithubHelp logo

新版本性能严重下降 about mix HOT 6 CLOSED

peinhu avatar peinhu commented on July 20, 2024
新版本性能严重下降

from mix.

Comments (6)

peinhu avatar peinhu commented on July 20, 2024

顺便压测了下还没发布的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.

onanying avatar onanying commented on July 20, 2024

@peinhu 我觉得需要贴一下 db 调用那部分的代码,我才能观察到问题的本质,我自己先尝试对比测试一下 2.1 vs 2.2

from mix.

peinhu avatar peinhu commented on July 20, 2024

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.

onanying avatar onanying commented on July 20, 2024

@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.

peinhu avatar peinhu commented on July 20, 2024

是不是2.1.9版本有问题?延迟低得吓人,性能也很高,但是压测过一次或者两次以后,从网页就无法访问那个接口了,一直在转没返回。现在的2.2.5版本性能没那么高,但是没这个问题,压测完还是可以正常访问。

from mix.

onanying avatar onanying commented on July 20, 2024

@peinhu 和这个没关系,v2.2 基本上都是从 v2.1 继承过来的,改变都是微调,应该是 v2.2 默认开启了访问日志(写文件),这个降低了一些性能。

from mix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.