search
HomeBackend DevelopmentPHP TutorialPHP framework performance test report_php skills

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 最短的单个请求

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

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

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

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

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

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

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


laravel:

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

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

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

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

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

Statement
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
2023年最流行的11款PHP框架2023年最流行的11款PHP框架Jul 07, 2022 pm 03:30 PM

什么是PHP框架?为什么要使用PHP框架?本篇文章就来和大家聊聊PHP框架的优势,并总结分享11款2023年最流行的PHP框架,希望对大家有所帮助!

2023年最流行的5个php开发框架视频教程推荐2023年最流行的5个php开发框架视频教程推荐May 08, 2017 pm 04:26 PM

如果想快速进行php web开发,选择一个好用的php开发框架至关重要,一个好的php开发框架可以让开发工作变得更加快捷、安全和有效。那2023年最流行的php开发框架有哪些呢?这些php开发框架排名如何?

如何使用PHP框架Lumen开发一个高效的消息推送系统,提供及时的推送服务如何使用PHP框架Lumen开发一个高效的消息推送系统,提供及时的推送服务Jun 27, 2023 am 11:43 AM

随着移动互联网的快速发展和用户需求的变化,消息推送系统已成为现代应用程序不可或缺的一部分,它能够实现即时通知、提醒、推广、社交等功能,为用户和商业客户提供更好的体验和服务。为了满足这一需求,本文将介绍如何使用PHP框架Lumen开发一个高效的消息推送系统,提供及时的推送服务。一、Lumen简介Lumen是由Laravel框架开发团队开发的一个微框架,它是一个

什么是PHP框架?PHP框架与CMS的区别什么是PHP框架?PHP框架与CMS的区别Jun 13, 2022 pm 02:21 PM

在编程中,框架扩展了构建通用软件应用程序的支撑结构。在你开始编码之前,框架就会将程序的基本功能插入到你的应用程序中,从而简化了软件的开发过程。

安全加固PHP框架的实施措施安全加固PHP框架的实施措施Aug 07, 2023 pm 06:41 PM

标题:安全加固PHP框架的实施措施引言:随着互联网的快速发展,安全问题成为了一个不可忽视的挑战。而作为最常用的编程语言之一,PHP的安全性也备受关注。为了提高PHP框架的安全性,我们需要采取一系列的实施措施。本文将介绍一些基本的安全加固措施,并提供相应的代码示例。一、输入过滤和验证1.1XSS(跨站脚本攻击)过滤在PHP框架中,使用htmlspecialc

使用PHP框架CodeIgniter开发一个实时聊天应用,提供便捷的通讯服务使用PHP框架CodeIgniter开发一个实时聊天应用,提供便捷的通讯服务Jun 27, 2023 pm 02:49 PM

随着移动互联网的发展,即时通信变得越来越重要,越来越普及。对于很多企业而言,实时聊天更像是一种通信服务,提供便捷的沟通方式,可以快速有效地解决业务方面的问题。基于此,本文将介绍如何使用PHP框架CodeIgniter开发一个实时聊天应用。了解CodeIgniter框架CodeIgniter是一个轻量级的PHP框架,提供了一系列的简便的工具和库,帮助开发者快速

如何使用PHP框架Yii开发一个高可用的云备份系统如何使用PHP框架Yii开发一个高可用的云备份系统Jun 27, 2023 am 09:04 AM

随着云计算技术的不断发展,数据的备份已经成为了每个企业必须要做的事情。在这样的背景下,开发一款高可用的云备份系统尤为重要。而PHP框架Yii是一款功能强大的框架,可以帮助开发者快速构建高性能的Web应用程序。下面将介绍如何使用Yii框架开发一款高可用的云备份系统。设计数据库模型在Yii框架中,数据库模型是非常重要的一部分。因为数据备份系统需要用到很多的表和关

深入探讨swoole协程与PHP框架的结合开发深入探讨swoole协程与PHP框架的结合开发Aug 05, 2023 pm 01:54 PM

深入探讨swoole协程与PHP框架的结合开发国内的互联网发展迅速,更多的开发者开始寻找高性能的解决方案来满足日益增长的用户需求。在PHP领域,swoole协程是一个备受关注的技术,它可以大幅提升PHP的性能,并且非常适合与PHP框架结合使用。本文将深入探讨swoole协程与PHP框架的结合开发,并附带一些代码示例。一、什么是swoole协程swoole是一

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment