PHP swoole 和 nodeJs性能分析_PHP教程
js出了个nodejs,我们技术老大前段时间发了个技术邮件说php支持多线程,异步,非阻塞 还打着旗号说要灭掉nodejs,官方网站上说swoole的性能已经最少也和nodejs可以媲美了,这个需要用数据说话,周末的时候有空就顺手测试了一下这两个东东!下面是测试报告哈。
首先我用127.0.0.1:8000端口测试swoole, 用127.0.0.1:1337测试nodejs
有图有真相:(稍后传,不会用mac把截图保存!汗!各位看客有谁会的教教我哈!编程都变傻了)
测试环境:
处理器:2.7GHz i7
内存:16GB 1600hz DDR3
系统 MAC OS X
先放测试结果:
1.PHPswoole的测试结果:
~mysql|? ab -n 5000 -c 100 http://127.0.0.1:8000/ This is ApacheBench, Version 2.3 <$Revision: 655654 $> 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 500 requests Completed 1000 requests Completed 1500 requests Completed 2000 requests Completed 2500 requests Completed 3000 requests Completed 3500 requests Completed 4000 requests Completed 4500 requests Completed 5000 requests Finished 5000 requests Server Software: Server Hostname: 127.0.0.1 Server Port: 8000 Document Path: / Document Length: 0 bytes Concurrency Level: 100 Time taken for tests: 1.411 seconds Complete requests: 5000 Failed requests: 0 Write errors: 0 Total transferred: 55330 bytes HTML transferred: 0 bytes Requests per second: 3543.00 [#/sec] (mean) Time per request: 28.225 [ms] (mean) Time per request: 0.282 [ms] (mean, across all concurrent requests) Transfer rate: 38.29 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 3 1.2 3 7 Processing: 17 25 16.7 23 143 Waiting: 1 9 12.9 7 136 Total: 20 28 16.6 26 143 Percentage of the requests served within a certain time (ms) 50% 26 66% 27 75% 27 80% 27 90% 28 95% 29 98% 141 99% 142 100% 143 (longest request)
2.nodejs的测试结果:
~mysql|? ab -n 5000 -c 100 http://127.0.0.1:1337/ This is ApacheBench, Version 2.3 <$Revision: 655654 $> 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 500 requests Completed 1000 requests Completed 1500 requests Completed 2000 requests Completed 2500 requests Completed 3000 requests Completed 3500 requests Completed 4000 requests Completed 4500 requests Completed 5000 requests Finished 5000 requests Server Software: Server Hostname: 127.0.0.1 Server Port: 1337 Document Path: / Document Length: 12 bytes Concurrency Level: 100 Time taken for tests: 1.215 seconds Complete requests: 5000 Failed requests: 0 Write errors: 0 Total transferred: 565000 bytes HTML transferred: 60000 bytes Requests per second: 4116.49 [#/sec] (mean) Time per request: 24.293 [ms] (mean) Time per request: 0.243 [ms] (mean, across all concurrent requests) Transfer rate: 454.26 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.6 0 5 Processing: 2 24 21.0 21 175 Waiting: 2 24 20.8 21 174 Total: 6 24 20.9 21 175 Percentage of the requests served within a certain time (ms) 50% 21 66% 22 75% 23 80% 24 90% 26 95% 32 98% 159 99% 170 100% 175 (longest request)
上面的ab测试中:每秒100的并发量共向接口请求5000次。
PHP和nodejs成绩都还不错,关键是Swoole的环境我用了--debug导致有很多命令会输出,暂时有不会改回去,(稍后在公司测试环境重新测试下)
Time taken for tests: 1.411 seconds 共耗时
Requests per second: 3543.00 [#/sec] (mean)
nodeJS
Time taken for tests: 1.215 seconds 共耗时
Requests per second: 4116.49 [#/sec] (mean)
从测试结果来看,虽然swoole的测试数据稍微逊色了一点,但是这并不影响我对swoole的看法(况且配置可能不是很好),我觉的对于一个C语言编写的PHP,这个已经比我们目前的环境要好的多了。

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

PHP和Python各有優勢,選擇依據項目需求。 1.PHP適合web開發,尤其快速開發和維護網站。 2.Python適用於數據科學、機器學習和人工智能,語法簡潔,適合初學者。

PHP在電子商務、內容管理系統和API開發中廣泛應用。 1)電子商務:用於購物車功能和支付處理。 2)內容管理系統:用於動態內容生成和用戶管理。 3)API開發:用於RESTfulAPI開發和API安全性。通過性能優化和最佳實踐,PHP應用的效率和可維護性得以提升。

PHP是一種廣泛應用於服務器端的腳本語言,特別適合web開發。 1.PHP可以嵌入HTML,處理HTTP請求和響應,支持多種數據庫。 2.PHP用於生成動態網頁內容,處理表單數據,訪問數據庫等,具有強大的社區支持和開源資源。 3.PHP是解釋型語言,執行過程包括詞法分析、語法分析、編譯和執行。 4.PHP可以與MySQL結合用於用戶註冊系統等高級應用。 5.調試PHP時,可使用error_reporting()和var_dump()等函數。 6.優化PHP代碼可通過緩存機制、優化數據庫查詢和使用內置函數。 7

PHP仍然具有活力,其在現代編程領域中依然佔據重要地位。 1)PHP的簡單易學和強大社區支持使其在Web開發中廣泛應用;2)其靈活性和穩定性使其在處理Web表單、數據庫操作和文件處理等方面表現出色;3)PHP不斷進化和優化,適用於初學者和經驗豐富的開發者。

PHP和Python各有優勢,選擇應基於項目需求。 1.PHP適合web開發,語法簡單,執行效率高。 2.Python適用於數據科學和機器學習,語法簡潔,庫豐富。

PHP和Python各有優劣,選擇取決於項目需求和個人偏好。 1.PHP適合快速開發和維護大型Web應用。 2.Python在數據科學和機器學習領域佔據主導地位。

PHP適合web開發,特別是在快速開發和處理動態內容方面表現出色,但不擅長數據科學和企業級應用。與Python相比,PHP在web開發中更具優勢,但在數據科學領域不如Python;與Java相比,PHP在企業級應用中表現較差,但在web開發中更靈活;與JavaScript相比,PHP在後端開發中更簡潔,但在前端開發中不如JavaScript。

PHP主要是過程式編程,但也支持面向對象編程(OOP);Python支持多種範式,包括OOP、函數式和過程式編程。 PHP適合web開發,Python適用於多種應用,如數據分析和機器學習。
