This content originally appeared on DEV Community and was authored by Max Bantsevich
Recently the Laravel Octane package was released. It was created to make Laravel with Swoole and RoadRunner more friendly. We are using RoadRunner instead of php-fpm in dev.family for some time now, and we decided to share our experience and to reveal what advantages it has.
RoadRunner is a high-performance, open-source PHP application server written in Go. The main difference from php-fpm is that RoadRunner interacts with long-lived php processes, unlike php-fpm, which creates and kills a new php process with each request.
Advantages of a long-lived process:
- No time wasted on booting
- No time is spent on creating a connection to the database
- The ability to use the in-memory cache directly in the process
The disadvantage of this approach is that it is not suitable for all PHP applications, because often when you are writing code, it is taken into account that the PHP process will die after the request. Thus, you need to be able to monitor memory leaks, work carefully with the global state. Therefore, legacy projects, probably, can’t be started on the Roadrunner.
However, Roadrunner has other useful functions, such as static feedback, response compression, and balancing. These functions in a typical bundle are falling on nginx. And if you are using the PHP roadrunner, the application can be raised without it at all (nginx).
RoadRunner is also quite easy to expand. You can use its components for your own application server and get the opportunity, for example, to process some requests directly on Go, to work with websockets.
RoadRunner itself is not a new development, it is already a couple of years old. However, with official support of Laravel Octane, you can be sure that the framework is ready to work with it.
We conducted a small test on a real project, where we compared the speed of php-fpm and roadrunner. The results were 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 result of a single query to the database in JSON format
There is a significant increase in speed, which is due to the lack of time for booting and the use of a permanent connection to the database.
This content originally appeared on DEV Community and was authored by Max Bantsevich
Max Bantsevich | Sciencx (2021-04-08T09:58:46+00:00) RoadRunner here and now. Retrieved from https://www.scien.cx/2021/04/08/roadrunner-here-and-now/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.