... 沙雕文章 勿信

file
file


 ab -n 1000 -c 100 http://127.0.0.1/test.php/
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.4.33
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /test.php/
Document Length:        233 bytes

Concurrency Level:      100
Time taken for tests:   0.407 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      513000 bytes
HTML transferred:       233000 bytes
Requests per second:    2458.74 [#/sec] (mean)
Time per request:       40.671 [ms] (mean)
Time per request:       0.407 [ms] (mean, across all concurrent requests)
Transfer rate:          1231.77 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.0      0       4
Processing:     3   38   7.4     38      59
Waiting:        1   38   7.5     38      59
Total:          3   39   7.0     39      59

Percentage of the requests served within a certain time (ms)
  50%     39
  66%     42
  75%     43
  80%     45
  90%     46
  95%     48
  98%     51
  99%     53
 100%     59 (longest request)


root@kali:~/Desktop# ab -n 1000 -c 100 http://127.0.0.1:1213/test.php/
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:        swoole-http-server
Server Hostname:        127.0.0.1
Server Port:            1213

Document Path:          /test.php/
Document Length:        3 bytes

Concurrency Level:      100
Time taken for tests:   0.920 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      191000 bytes
HTML transferred:       3000 bytes
Requests per second:    1087.36 [#/sec] (mean)
Time per request:       91.966 [ms] (mean)
Time per request:       0.920 [ms] (mean, across all concurrent requests)
Transfer rate:          202.82 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.8      0       3
Processing:     5   87  34.0     84     264
Waiting:        2   87  34.0     84     264
Total:          6   88  33.6     85     264

Percentage of the requests served within a certain time (ms)
  50%     85
  66%     90
  75%     98
  80%    102
  90%    111
  95%    123
  98%    249
  99%    257
 100%    264 (longest request)

>Apache  Requests per second:    2458.74 [#/sec] (mean)
>swoole Requests per second:    1087.36 [#/sec] (mean)

debug模式已关闭
1213端口是swoole的  居然比Apache慢一倍!!!
姿势不对? 我测试很很多次了  还是一个样子

专心学习不瞎搞
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 16

今晚我用我服务器测试看看 哪位大佬有时间 也可以装swooletw/Laravel-swoole 测试速度

5年前 评论
leo

你的 test.php 是什么内容

5年前 评论

<?php
echo "hello word";

5年前 评论

兩邊都是在 laravel 上測試的?還是 test.php 是單個 php 檔案?

5年前 评论

原則上這個 package 做的事就是把 laravel 在 swoole server 上執行,以節省每次 laravel 框架加載與初始化的時間,參考的測試結果都有附在 github 的說明頁上

如果自己測出來的結果不如預期,影響因素實在太多,可能和你的機器配置和系統設定有很大的關聯,建議用乾淨的系統環境和乾淨的 laravel 專案來進行測試

5年前 评论

laravel目录下/public/test.php
这个test.php并不走index.php的

5年前 评论

這個測試方式有問題,這樣程式完全沒有過到 laravel,你應該要像這樣測試:

Route::get('test', function() {
    return 'hello world';
});
5年前 评论

另外建議更改一下這篇文章誘導式的內容農場殺人標題

5年前 评论

@albert_chen laravel-swoole 比传统 fpm 更快是母庸质疑的,我担心的是长时间 php cli 模式会不会造成频繁 gc 或者内存泄漏,因为服务器一般是不会定时重启的,内存泄漏严重影响服务器性能。现在各种协程框架例如 swoft 都有自己的对象池防止频繁 gc 影响性能,不知道 laravel-swoole 有没有计划搞类似的东西。@albert_chen

5年前 评论

@leoyang 這是個非常好的問題,laravel-swoole 若要在 laravel container 中針對各組件導入對象池是有一定困難的,原因在於 laravel 不像是 swoft 這種本來就是基於 swoole 的框架,各組件並沒有 reset 的機制,需要自己透過 laravel-swoole 所提供的 resetter 或是 service provider 來手動實踐對各組件的 reset 邏輯,且若是要讓各個基於 container 下的組件們也支援對象池的話,需要對 container 本身做一定程度侵入式的改寫,目前會盡量避免做這樣的更動,但如果是針對 container 本身設計對象池是有可能的,只是如此成效可能不大

至於是隨著時間會有緩慢的內存洩露問題這個目前還沒有好的解法,但能透過 swoole server 中的 max request 參數來使 worker 在處理完一定的 request 數量後自動重啟,進而解決這個問題

5年前 评论

@albert_chen 有道理,只要 max request 参数设置正确应该就没有内存泄漏的问题了,gc 这个估计只能等 laravel 自己支持对象池才能解决问题了

5年前 评论

@leoyang 沒錯,只是對象池模式應該很難被 laravel 官方本身所支援,因為在一般 php 的運作環境下,並不存在單個 worker 內的異步併發場景,同步阻塞下只需要 singleton 模式便夠用了 :joy:

5年前 评论

@albert_chen 感觉异步协程框架是以后的趋势,毕竟并发量优势非常明显,laravel 本身不支持这样的模式很可惜,也很危险。另外 singleton 模式很可能会带有上次对象的信息,还是需要在回调函数进行初始化才行。

5年前 评论

@lyxxxh 我现在也发现这个问题了,本地是swoole比php-fpm快好几倍速,但线上服务器却是明显的php-fpm比swoole快好多,你可解决这个问题了?

4年前 评论

@lyxxxh 我解决了,多开几个work进程就好了

4年前 评论

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