Mainstream PHP Framework performance non-authoritative test
As a PHP developer and a technology developer for a start-up team, choosing a development framework is a tough thing to do.
With thinkphp, recruiting a developer who just came out of the training organization can get started, but performance and later code decoupling is a headache. However, many third-party functions do not need to write their own, many Daniel has paved the way.
With laravel words, the legend is very cool to write, but the cost of learning is a bit high, you can not give junior developers half a month to learn the framework bar. And it is said that the lake people revealed that laravel performance is not good, the document is not particularly rich.
With yii words, grammar a bit verbose, front and rear code separation a little trouble, but the performance is very good, and there are many large domestic companies in use, there are accidents can quickly find Daniel answers.
As a simple performance evaluation, choose a performance of the total will not be wrong
Performance testing
Test Date: May 06, 2016
Test tool: Siege (because the AB of Mac system always appears pr_socket_recv:connection reset by peer (54) error, so selected siege)
Test machine: MacPro Core i5 processor/8GB Memory/256GB SSD Flash
Test environment: Apache PHP5.6
Framework version: thinkphp 3.2.3 Laravel 5.2 Yii2.0.5
Test principle: 5 times per test cycle, medium data
Additional note: All projects are made in sub-directories
Result description
Transactions: 2119 hits processing requests total availability: 96.85% availability elapsed time: 9.74 secs Runtime data Transferred: 1.31 MB Data transfer response time: 0.60 secs response times Transaction rate: 217.56 trans/sec per second processing efficiency throughput : 0.13 mb/sec processing data per second concurrency: 130.28 Concurrent Successful transactions: 2162 Successful request failed transactions: 69 failed Requests longest transaction: 2.85 maximum single request shortest transaction: 0.01 Shortest single request
Start testing
Add a controller and enter 10,000 times in the controller HelloWorld
Concurrent 50 Cycles 10 times
The first thing that comes to us is thinkphp, it looks fine.
Transactions: hitsavailability: 100.00%elapsed time: 2.81 Secsdata transferred: 52.45 Mbresponse time: 0.26 secstransaction rate: 177.94 trans/secthroughput: 18.67 mb/secconcurrency: 47.10Successful transactions: 500Failed transactions: 0Longest transaction: 0.48Shortest transaction: 0.03
And then Laravle, um, slightly disappointed.
Transactions: hitsavailability: 100.00%elapsed time: 13.33 Secsdata transferred: 52.45 Mbresponse time: 1.27 secstransaction rate: 37.51 trans/secthroughput: 3.93 mb/secconcurrency: 47.55Successful transactions: 500Failed transactions: 0Longest transaction: 3.64Shortest transaction: 0.07
The last pre-match yii that was more bullish
Transactions: hitsavailability: 100.00%elapsed time: 4.84 Secsdata transferred: 52.45 Mbresponse time: 0.46 secstransaction rate: 103.31 trans/secthroughput: 10.84 mb/secconcurrency: 47.65Successful transactions: 500Failed transactions: 0Longest transaction: 0.88Shortest transaction: 0.04
Concurrent 200 Cycles 10 times
First, thinkphp.
Transactions: 1977 hitsavailability: 98.85%elapsed time: 10.03 Secsdata transferred: 207.40 Mbresponse time: 0.95 secstransaction Rate: 197.11 trans/secthroughput: 20.68 mb/secconcurrency: 187.68Successful transactions: 1977Failed transactions: 23Longest transaction: 1.22Shortest Transaction: 0.02
And then the Laravel.
Transactions: 1890 hitsavailability: 94.50%elapsed time: 51.85 Secsdata transferred: 198.27 Mbresponse time: 4.88 secstransaction rate: 36.45 trans/secthroughput: 3.82 mb/secconcurrency: 178.00Successful transactions: 1890Failed transactions: 110Longest transaction: 26.01Shortest Transaction: 0.07
And finally, Yii.
Transactions: 1996 hitsavailability: 99.80%elapsed time: 18.95 Secsdata transferred: 209.39 Mbresponse time: 1.79 secstransaction rate: 105.33 trans/secthroughput: 11.05 mb/secconcurrency: 188.57Successful transactions: 1996Failed transactions: 4Longest transaction: 3.29Shortest Transaction: 0.10
Unexpectedly in the absence of optimization, thinkphp speed is the fastest, yii a little more, Laravel hobbled run out of the test. The result is somewhat unexpected, but the above test represents only the development environment, and the framework is optimized to simulate the online environment.
Optimization framework
thinkphp:
App_debug Change to False
Laravel:
App_debug instead of falsephp artisan route:cachephp artisan optimizephp Artisan config:cachecomposer Dumpautoload-o
YII:
Yii_debug to Falsecomposer Dumpautoload-o
Concurrent 200 Cycles 10 times
thinkphp
Transactions: 1655 hitsavailability: 82.75%elapsed time: 8.21 Secsdata transferred: 173.62 Mbresponse time: 0.69 secstransaction rate: 201.58 trans/secthroughput: 21.15 mb/secconcurrency: 139.29Successful transactions: 1655Failed transactions: 345Longest transaction: 7.83Shortest Transaction: 0.00
Laravel:
Transactions: 1520 hitsavailability: 76.00%elapsed time: 34.95 Secsdata transferred: 159.45 Mbresponse time: 3.15 secstransaction rate: 43.49 trans/secthroughput: 4.56 mb/secconcurrency: 136.84Successful transactions: 1520Failed transactions: 480Longest transaction: 19.18Shortest Transaction: 0.00
YII:
Transactions: 1704 hitsavailability: 85.20%elapsed time: 15.16 Secsdata transferred: 178.76 Mbresponse time: 1.46 secstransaction rate: 112.40 trans/secthroughput: 11.79 mb/secconcurrency: 164.21Successful transactions: 1704Failed transactions: 296Longest transaction: 9.04Shortest Transaction: 0.00
Oddly enough, when the framework turns off debug mode, there are more failures. However, it is obvious that the performance of Laravel is greatly improved after simple optimization, but it is still lower than the other two frameworks.
Conclusion
In the process of testing, other my mood is depressed, feel their own three-view world has collapsed, collapse to slag.
thinkphp performance than Yii is one times higher than Laravel, nearly four times times the performance of Yii is more moderate, but in the test will obviously find that the situation of request failure than the other two frameworks less laravel still elegant, but the performance is worrying, use the words of the netizen to describe more studious people die
At last
My project finally used a self-built framework for development, thanks to the strong composer, the development process was very smooth, and finally attached to its own framework in 200 concurrent 10 cycles of data, framework open source But the update is busy, welcome to search ppphp on GitHub, and I build the framework.
Transactions: 1672 hitsavailability: 83.60%elapsed time: 6.18 Secsdata transferred: 175.40 Mbresponse time: 0.57 secstransaction rate: 270.55 trans/secthroughput: 28.38 mb/secconcurrency: 153.16Successful transactions: 1672Failed transactions: 328Longest transaction: 4.57Shortest Transaction: 0.01
Appreciation support Author write more Good articles, thank you!
Reward authors
Appreciation support Author write more Good articles, thank you!
Choose a payment method
About the author: Lee Tiger head
Worked in 11Space as a PHP architect, ppphp framework author homepage · My article · 1 ·