DEV Community

Cover image for RoadRunner here and now
Max Bantsevich for

Posted on

RoadRunner here and now

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 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:

plain text: 1150 RPS
single query: 530 RPS

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.

Top comments (1)

necmettin profile image
Necmettin Begiter

php-fpm .. creates and kills a new php process with each request

php-fpm does not create a new php process for every request. It allows you to program its behavior. You can easily have php-fpm create/recycle a new PHP process for every millionth request. You can easily have 20 php processes run simultaneously and handle hundreds of thousands of requests per second.