Home > Backend Development > PHP Tutorial > PHP framework performance test report_php skills

PHP framework performance test report_php skills

WBOY
Release: 2016-05-16 09:00:18
Original
2020 people have browsed it

as a php developer and a technical developer on a start-up team, choosing a development framework is a very difficult thing.

with thinkphp, you can get started by recruiting a developer who has just graduated from a training institution, but decoupling performance and post-code is a headache. however, many third-party functions do not need to be written by yourself, as many experts have already paved the way.

with laravel, legend is very comfortable to write and has sufficient scalability, but the learning cost is a bit high. you can’t give junior developers half a month to learn the framework. and it is said that people in the world have revealed that laravel’s performance is not very good, and the documentation is not particularly rich.

with yii, the syntax is a bit verbose, and the separation of front-end and back-end code is a little troublesome, but the performance is very good, and it is already used by many large domestic companies. if something unexpected happens, you can quickly find an expert to answer your questions.

it’s better to do a simple performance evaluation. you can’t go wrong by choosing one with excellent performance

performance test
test time: may 6, 2016
test tool: siege (because the error pr_socket_recv: connection reset by peer (54) always occurs in ab of mac system, so i chose siege)
test machine: macpro core i5 processor/8gb memory/256gb ssd flash memory
test environment: apache php5.6
framework version: thinkphp 3.2.3 laravel 5.2 yii2.0.5
testing principle: each test cycle is 5 times, and medium data is taken
additional note: all projects are placed in subdirectories

explanation of results

transactions:        2119 hits 处理请求总数量
availability:        96.85 % 可用性
elapsed time:        9.74 secs 运行时间
data transferred:      1.31 mb 数据传输量
response time:        0.60 secs 响应时间
transaction rate:     217.56 trans/sec 每秒处理效率
throughput:        0.13 mb/sec 每秒处理数据
concurrency:       130.28 并发
successful transactions:    2162 成功的请求
failed transactions:       69 失败的请求
longest transaction:      2.85 最长的单个请求
shortest transaction:      0.01 最短的单个请求
Copy after login

start testing

add a controller and enter helloworld 10,000 times in the controller

concurrency 50 cycles 10 times:

the first thing that came to us was thinkphp, which looked okay

transactions:         500 hits
availability:       100.00 %
elapsed time:        2.81 secs
data transferred:      52.45 mb
response time:        0.26 secs
transaction rate:     177.94 trans/sec
throughput:        18.67 mb/sec
concurrency:        47.10
successful transactions:     500
failed transactions:        0
longest transaction:      0.48
shortest transaction:      0.03

Copy after login

then laravle, well, a little disappointed

transactions:         500 hits
availability:       100.00 %
elapsed time:        13.33 secs
data transferred:      52.45 mb
response time:        1.27 secs
transaction rate:      37.51 trans/sec
throughput:        3.93 mb/sec
concurrency:        47.55
successful transactions:     500
failed transactions:        0
longest transaction:      3.64
shortest transaction:      0.07

Copy after login

yii, who was relatively optimistic before the final game

transactions:         500 hits
availability:       100.00 %
elapsed time:        4.84 secs
data transferred:      52.45 mb
response time:        0.46 secs
transaction rate:     103.31 trans/sec
throughput:        10.84 mb/sec
concurrency:        47.65
successful transactions:     500
failed transactions:        0
longest transaction:      0.88
shortest transaction:      0.04

Copy after login

200 concurrent loops 10 times:

first is thinkphp

transactions:        1977 hits
availability:        98.85 %
elapsed time:        10.03 secs
data transferred:     207.40 mb
response time:        0.95 secs
transaction rate:     197.11 trans/sec
throughput:        20.68 mb/sec
concurrency:       187.68
successful transactions:    1977
failed transactions:       23
longest transaction:      1.22
shortest transaction:      0.02

Copy after login

then laravel

transactions:        1890 hits
availability:        94.50 %
elapsed time:        51.85 secs
data transferred:     198.27 mb
response time:        4.88 secs
transaction rate:      36.45 trans/sec
throughput:        3.82 mb/sec
concurrency:       178.00
successful transactions:    1890
failed transactions:       110
longest transaction:      26.01
shortest transaction:      0.07

Copy after login

finally yii

transactions:        1996 hits
availability:        99.80 %
elapsed time:        18.95 secs
data transferred:     209.39 mb
response time:        1.79 secs
transaction rate:     105.33 trans/sec
throughput:        11.05 mb/sec
concurrency:       188.57
successful transactions:    1996
failed transactions:        4
longest transaction:      3.29
shortest transaction:      0.10

Copy after login

unexpectedly, without optimization, thinkphp was the fastest, yii was slightly faster, and laravel finished the test falteringly. the results are somewhat unexpected, but the above test only represents the development environment. the framework will be optimized below to simulate the online environment.

optimization framework

thinkphp:

app_debug改为false


Copy after login

laravel:

app_debug改为false
php artisan route:cache
php artisan optimize
php artisan config:cache
composer dumpautoload -o

Copy after login

yii:

yii_debug changed to false
composer dumpautoload -o
concurrency 200 loops 10 times:

thinkphp

transactions:        1655 hits
availability:        82.75 %
elapsed time:        8.21 secs
data transferred:     173.62 mb
response time:        0.69 secs
transaction rate:     201.58 trans/sec
throughput:        21.15 mb/sec
concurrency:       139.29
successful transactions:    1655
failed transactions:       345
longest transaction:      7.83
shortest transaction:      0.00

Copy after login

laravel:

transactions:        1520 hits
availability:        76.00 %
elapsed time:        34.95 secs
data transferred:     159.45 mb
response time:        3.15 secs
transaction rate:      43.49 trans/sec
throughput:        4.56 mb/sec
concurrency:       136.84
successful transactions:    1520
failed transactions:       480
longest transaction:      19.18
shortest transaction:      0.00

Copy after login

yii:

transactions:        1704 hits
availability:        85.20 %
elapsed time:        15.16 secs
data transferred:     178.76 mb
response time:        1.46 secs
transaction rate:     112.40 trans/sec
throughput:        11.79 mb/sec
concurrency:       164.21
successful transactions:    1704
failed transactions:       296
longest transaction:      9.04
shortest transaction:      0.00
Copy after login

what is strange is that when the framework turns off debugging mode, there are more failures. however, it is obvious that after simple optimization, laravel's performance has been greatly improved, but it is still lower than the other two frameworks.

conclusion

during the test, i felt depressed and felt that my world view had collapsed to the point of collapse.

thinkphp’s performance is twice as high as yii and nearly four times higher than laravel
the performance of yii is relatively mediocre, but in the test, it is obvious that there are fewer request failures than the other two frameworks
laravel is still elegant, but its performance is worrying. it is better to describe it in the words of netizens: those who learn will live, those who use it will die

finally

my project was finally developed using a self-built framework. thanks to the power of composer, the development process went very smoothly. finally, i attached the data of the self-built framework running 200 concurrent cycles for 10 times. the framework is open source but the update is quite busy. welcome to search ppphp on github and build the framework with me.

Transactions:        1672 hits
Availability:        83.60 %
Elapsed time:        6.18 secs
Data transferred:     175.40 MB
Response time:        0.57 secs
Transaction rate:     270.55 trans/sec
Throughput:        28.38 MB/sec
Concurrency:       153.16
Successful transactions:    1672
Failed transactions:       328
Longest transaction:      4.57
Shortest transaction:      0.01
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template