In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how to improve the speed of PHP programs. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The Laravel Octane package (https://github.com/laravel/octane) has recently been released. Its creation makes Laravel more friendly to Swoole and RoadRunner. We've been using RoadRunner in dev.family instead of php-fpm for some time, and we decided to share our experience and reveal its advantages.
RoadRunner is a high-performance, open source PHP application server written in Go. The main difference from php-fpm is that RoadRunner interacts with php's resident process, unlike php-fpm, which creates and kills a new php process at each request.
Advantages of resident processes:
There is no time to waste on startup
No time is spent creating a connection to the database
The ability to use memory caching directly in a process
The disadvantage of this approach is that it is not suitable for all PHP applications, as code is usually written with the PHP process terminated after a request. Therefore, you need to be able to monitor memory leaks and carefully handle the global state. Therefore, legacy projects may not be able to start on Roadrunner.
However, Roadrunner has other useful features, such as static feedback, response compression, and balancing. The functions of typical bundles fall on nginx. If you use PHP Roadrunner, you can start the application (nginx) without it.
RoadRunner is also easy to extend. You can use its components for your own application server and get the opportunity, for example, you can use websockets to process some requests directly on the Go.
RoadRunner itself is not a new development project, it has a history of several years. However, with Laravel Octane's official support, you can be sure that the framework is ready to use it.
We did a little test on a real project to compare the speed of php-fpm and roadrunner. The results are as follows:
Php-fpm:
Plain text: 1150 RPS
Single query: 530 RPS
Roadrunner:
Plain text: 2200 RPS
Single query: 1600 RPS
Plain text-A query that returns a constant JSON
Single query-A query that returns the results of a single query to the database in JSON format
The speed has increased significantly due to the lack of startup time and the use of a permanent connection to the database.
Thank you for reading! This is the end of the article on "how to improve the speed of PHP programs". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.