<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                看到嗶哩嗶哩有個視頻對比golang和webman helloword壓力測試性能,webman比goloang低了很多,低我理解,golang畢竟多線程自帶協程,而且webman是框架,golang是http標準庫,不在一個層次,但是感覺不會低這么多才對。還有我覺得應該是golang的http標準庫和workerman對比才公平。 所以我特地買了臺aliyun服務器測試下,順便把swoole workerman也壓測了下,結果也發到了群里,既然測試了就記錄下來給大家參考下,代碼都有大家可以自行測試。 ## 環境配置: * 4核(vCPU) 4 GiB Ubuntu 20.04 64位 * PHP 7.4.3 * Go version go1.13.8 linux/amd64 ## 壓測命令 `ab -n100000 -c200 http://127.0.0.1:xxx/`沒開keepalive `ab -n100000 -c200 -k http://127.0.0.1:xxx/`開了keepalive ## 進程數(線程數數): 對go不熟悉,不知道go怎么開多進程,為了公平起見我默認workerman webman swoole 全部1個進程,go就是教程里的helloword代碼,應該也是一個進程,是不是多線程我不知道。 ## 先貼結果: | | 沒開keepalive | 開了keepalive | | --- | --- | --- | | golang | 19995 | 98546 | | workerman | 30120 | 125986 | | webman | 29301 | 85938 | | swoole | 25836 | 73304 | | swoole+協程 | 27093 | 54596 | 結果是workeman壓測性能高于golang,webman短連接高于golang,keepalive長連接略低于golang。 swoole短連接高于golang,keepalive低于golang。workerman和webman不管是短連接還是keepliave都高于swoole。 ## go代碼 ~~~ package main import ( "net/http" ) func handler(w http.ResponseWriter,r *http.Request) { w.Write([]byte("hello")) } func main() { http.HandleFunc("/",handler) http.ListenAndServe(":8080",nil) } ~~~ ## workerman代碼 ~~~php require_once __DIR__ . '/vendor/autoload.php'; use Workerman\Worker; $worker = new Worker('http://0.0.0.0:12345'); $worker->onMessage = function($connection, $request) { // 不加-k參數時要用close才行? $connection->close('hello'); }; Worker::runAll(); ~~~ ~~~php require_once __DIR__ . '/vendor/autoload.php'; use Workerman\Worker; $worker = new Worker('http://0.0.0.0:12345'); $worker->onMessage = function($connection, $request) { // 不加-k時用send $connection->send('hello'); }; Worker::runAll(); ~~~ workerman這里不太好,ab測試時-k 參數需要自己區別處理,所以需要兩個腳本 ## webman代碼 ~~~php <?php namespace app\controller; use support\Request; class Index { public function index(Request $request) { return 'hello'; } } ~~~ ## swoole代碼 ~~~php <?php $http = new Swoole\Http\Server('0.0.0.0', 12346, SWOOLE_BASE); $http->on('Request', function ($request, $response) { $response->end('hello'); }); $http->start(); ~~~ ## swoole協程代碼 ~~~php <?php use Swoole\Coroutine\Http\Server; use function Swoole\Coroutine\run; run(function () { $server = new Server('127.0.0.1', 9502, false); $server->handle('/', function ($request, $response) { $response->end("hello"); }); $server->start(); }); ~~~ ## 不開keep-alive結果截圖: [截圖](https://www.workerman.net/upload/img/20220510/106279e1e6de54.png) [截圖](https://www.workerman.net/upload/img/20220510/106279e1ef3e76.png) [截圖](https://www.workerman.net/upload/img/20220510/106279e1f6cbcd.png) [截圖](https://www.workerman.net/upload/img/20220510/106279e2005f2e.png) [截圖](https://www.workerman.net/upload/img/20220510/106279e2074aba.png) ## 開keep-alive結果截圖 [截圖](https://www.workerman.net/upload/img/20220510/106279e2200440.png) [截圖](https://www.workerman.net/upload/img/20220510/106279e228d8f0.png) [截圖](https://www.workerman.net/upload/img/20220510/106279e22e224d.png) [截圖](https://www.workerman.net/upload/img/20220510/106279e2388f45.png) [截圖](https://www.workerman.net/upload/img/20220510/106279e23ef282.png) ## 最后 我知道肯定會有人說helloword壓測沒有意義,但是我覺得還有一定意義的,畢竟代表了框架的極限性能啊。 [https://learnku.com/laravel/t/63523](https://learnku.com/laravel/t/63523) 另外這里也有一個golang框架與webman的比較,帶簡單業務的,大家也可以參考的
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看