GithubHelp home page GithubHelp logo

🪶 在 C++ 中,有提供了Socket sendfile的方法(zerocopy),可以不通过CPU去调度资源,避免重复拷贝两次DMZ(或者更多) about swoole-src HOT 15 OPEN

tianxiu2b2t avatar tianxiu2b2t commented on July 18, 2024
🪶 在 C++ 中,有提供了Socket sendfile的方法(zerocopy),可以不通过CPU去调度资源,避免重复拷贝两次DMZ(或者更多)

from swoole-src.

Comments (15)

NathanFreeman avatar NathanFreeman commented on July 18, 2024

你用的是httpserver还是tcpserver

from swoole-src.

tianxiu2b2t avatar tianxiu2b2t commented on July 18, 2024

http基于TCP的,理论上支持

from swoole-src.

NathanFreeman avatar NathanFreeman commented on July 18, 2024

你是压测的过程中发现假死的吗,可以的话提供一下复现代码和压测命令

from swoole-src.

tianxiu2b2t avatar tianxiu2b2t commented on July 18, 2024

我只能提供文件数量和大小,压测命令我暂时没有,但可以提供数据

from swoole-src.

tianxiu2b2t avatar tianxiu2b2t commented on July 18, 2024

五分钟QPS:13570
文件数量:124k
大小:125G
最大文件大小:100MB左右
最小文件:64b或者是0b

from swoole-src.

NathanFreeman avatar NathanFreeman commented on July 18, 2024

你是用Swoole\Http\Response::end还是Swoole\Http\Response::sendfile方法发送文件

from swoole-src.

tianxiu2b2t avatar tianxiu2b2t commented on July 18, 2024

只有sendfile,没有end

from swoole-src.

NathanFreeman avatar NathanFreeman commented on July 18, 2024
<?php
$http = new Swoole\Http\Server('127.0.0.1', 9501, SWOOLE_PROCESS);

$http->on('start', function ($server) {
    echo "Swoole http server is started at http://127.0.0.1:9501\n";
});

$http->on('request', function ($request, $response) {
    $response->header('Content-Type', 'application/octet-stream');
    $response->header('Content-Disposition', 'attachment; filename=recvfile.txt');
    $response->sendfile('/home/sendfile.txt');
});

$http->start();

传输文件是100M的,wrk -c20000 -t4 -d120s http://127.0.0.1:9501/ 压测命令

你的服务器环境是怎么样的,代码是我这样的写法吗

from swoole-src.

NathanFreeman avatar NathanFreeman commented on July 18, 2024

php -m查看一下扩展列表,php --ri swoole查看一下swoole信息

from swoole-src.

tianxiu2b2t avatar tianxiu2b2t commented on July 18, 2024

服务器环境:4h8g,php占用6g
php -m zstd拓展,swoole是最新版本的

from swoole-src.

tianxiu2b2t avatar tianxiu2b2t commented on July 18, 2024

另外,是Swoole\Coroutine\Http\Server

from swoole-src.

NathanFreeman avatar NathanFreeman commented on July 18, 2024

有内存泄漏,我看看是哪里的问题

from swoole-src.

tianxiu2b2t avatar tianxiu2b2t commented on July 18, 2024

我怀疑是客户端正确关闭后,没有自动释放,导致有引用计数不能为0的情况
可以看看是否客户端关闭没有通知response关闭?

from swoole-src.

tianxiu2b2t avatar tianxiu2b2t commented on July 18, 2024

因为连接数导致内存上涨和没有正确释放等问题

from swoole-src.

NathanFreeman avatar NathanFreeman commented on July 18, 2024

我测试了一下,这个应该不是内存泄漏,更有可能是因为php的内存管理机制会将小的内存块保留起来不还给操作系统。
使用Swoole\Timer::tick设置合适的时间间隔调用gc_mem_caches()强制php归还内存给操作系统试试看。

from swoole-src.

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.