search
HomeBackend DevelopmentPHP TutorialTake a quick look! Non-authoritative test of mainstream PHP framework performance

Non-authoritative test of mainstream PHP framework performance

As a PHP developer and a technical developer of a start-up team, choosing a development framework is a very difficult thing.

If you use 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.

If you use Laravel, it is said that it 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 the performance of Laravel is not very good, and the documentation is not particularly rich.

If you use Yii, the syntax is a bit cumbersome, 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 an accident occurs, you can quickly Find Daniel 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

  • Testing time: May 2016 06th

  • Test tool: siege (Because ab of MAC system always appears pr_socket_recv: Connection reset by peer ( 54) error, 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, taking medium data

Supplementary instructions: All projects are Let's start the test in the subdirectory

Result Description

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

Add a controller and enter HelloWorld 10,000 times in the controller

Concurrency 50 loops 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 came 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

In the end, Yii

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

, which was more optimistic before the game, was concurrently 200 and looped 10 times:

First was 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 was 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 It's 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

I didn't expect that 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改为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

The strange thing is that when the framework turns off the 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. I 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

  • Yii’s performance is relatively mediocre, but in the test Zhonghui clearly found that there were 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 use it The person who dies

Finally

My project was developed using a self-built framework. Thanks to the power of composer, the development process went very smoothly. In the end Attached is the data of 200 concurrency and 10 cycles of our own framework. The framework is open source but very busy with updates. You are 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

The above is the detailed content of Take a quick look! Non-authoritative test of mainstream PHP framework performance. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

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 Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool