Home Backend Development PHP Tutorial PHP framework performance test report_php skills

PHP framework performance test report_php skills

May 16, 2016 am 09:00 AM
php framework Performance Testing

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

1

2

3

4

5

6

7

8

9

10

11

12

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

1

2

3

4

5

6

7

8

9

10

11

12

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

1

2

3

4

5

6

7

8

9

10

11

12

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

1

2

3

4

5

6

7

8

9

10

11

12

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

1

2

3

4

5

6

7

8

9

10

11

12

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

1

2

3

4

5

6

7

8

9

10

11

12

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

1

2

3

4

5

6

7

8

9

10

11

12

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:

1

app_debug改为false

Copy after login

laravel:

1

2

3

4

5

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

1

2

3

4

5

6

7

8

9

10

11

12

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:

1

2

3

4

5

6

7

8

9

10

11

12

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:

1

2

3

4

5

6

7

8

9

10

11

12

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.

1

2

3

4

5

6

7

8

9

10

11

12

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

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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Comparison of the advantages and disadvantages of PHP frameworks: Which one is better? Comparison of the advantages and disadvantages of PHP frameworks: Which one is better? Jun 04, 2024 pm 03:36 PM

The choice of PHP framework depends on project needs and developer skills: Laravel: rich in features and active community, but has a steep learning curve and high performance overhead. CodeIgniter: lightweight and easy to extend, but has limited functionality and less documentation. Symfony: Modular, strong community, but complex, performance issues. ZendFramework: enterprise-grade, stable and reliable, but bulky and expensive to license. Slim: micro-framework, fast, but with limited functionality and a steep learning curve.

Performance differences of PHP frameworks in different development environments Performance differences of PHP frameworks in different development environments Jun 05, 2024 pm 08:57 PM

There are differences in the performance of PHP frameworks in different development environments. Development environments (such as local Apache servers) suffer from lower framework performance due to factors such as lower local server performance and debugging tools. In contrast, a production environment (such as a fully functional production server) with more powerful servers and optimized configurations allows the framework to perform significantly better.

PHP Frameworks and Microservices: Cloud Native Deployment and Containerization PHP Frameworks and Microservices: Cloud Native Deployment and Containerization Jun 04, 2024 pm 12:48 PM

Benefits of combining PHP framework with microservices: Scalability: Easily extend the application, add new features or handle more load. Flexibility: Microservices are deployed and maintained independently, making it easier to make changes and updates. High availability: The failure of one microservice does not affect other parts, ensuring higher availability. Practical case: Deploying microservices using Laravel and Kubernetes Steps: Create a Laravel project. Define microservice controllers. Create Dockerfile. Create a Kubernetes manifest. Deploy microservices. Test microservices.

Integration of PHP frameworks with DevOps: the future of automation and agility Integration of PHP frameworks with DevOps: the future of automation and agility Jun 05, 2024 pm 09:18 PM

Integrating PHP frameworks with DevOps can improve efficiency and agility: automate tedious tasks, free up personnel to focus on strategic tasks, shorten release cycles, accelerate time to market, improve code quality, reduce errors, enhance cross-functional team collaboration, and break down development and operations silos

The best PHP framework for microservice architecture: performance and efficiency The best PHP framework for microservice architecture: performance and efficiency Jun 03, 2024 pm 08:27 PM

Best PHP Microservices Framework: Symfony: Flexibility, performance and scalability, providing a suite of components for building microservices. Laravel: focuses on efficiency and testability, provides a clean API interface, and supports stateless services. Slim: minimalist, fast, provides a simple routing system and optional midbody builder, suitable for building high-performance APIs.

Which PHP framework offers the most comprehensive extension library for rapid development? Which PHP framework offers the most comprehensive extension library for rapid development? Jun 04, 2024 am 10:45 AM

The PHP framework extension library provides four frameworks for selection: Laravel: Known for its vast ecosystem and third-party packages, it provides authentication, routing, validation and other extensions. Symfony: Highly modular, extending functionality through reusable "Bundles", covering areas such as authentication and forms. CodeIgniter: lightweight and high-performance, providing practical extensions such as database connection and form validation. ZendFramework: Powerful enterprise-level features, with extensions such as authentication, database connection, RESTfulAPI support, etc.

The application potential of artificial intelligence in PHP framework The application potential of artificial intelligence in PHP framework Jun 03, 2024 am 11:01 AM

The application potential of Artificial Intelligence (AI) in PHP framework includes: Natural Language Processing (NLP): for analyzing text, identifying emotions and generating summaries. Image processing: used to identify image objects, face detection and resizing. Machine learning: for prediction, classification and clustering. Practical cases: chatbots, personalized recommendations, fraud detection. Integrating AI can enhance website or application functionality, providing powerful new features.

PHP Frameworks and Artificial Intelligence: A Developer's Guide PHP Frameworks and Artificial Intelligence: A Developer's Guide Jun 04, 2024 pm 12:47 PM

Use a PHP framework to integrate artificial intelligence (AI) to simplify the integration of AI in web applications. Recommended framework: Laravel: lightweight, efficient, and powerful. CodeIgniter: Simple and easy to use, suitable for small applications. ZendFramework: Enterprise-level framework with complete functions. AI integration method: Machine learning model: perform specific tasks. AIAPI: Provides pre-built functionality. AI library: handles AI tasks.

See all articles