New Dedicated Application Server Revs PHP to Peak Performance
Find the perfect platform for you!
Join the DZone community and get the full member experience.Join For Free
Running a PHP application offers a wholly unique experience compared to running applications in other programming languages like Java or Golang. In most languages, you have to start your application in order to respond to a client request; whereas, with PHP, you have a simple “.php” file that sits quietly until it is invoked by a top-level web server like Nginx+PHP-FPM or Apache mod_php.
You may also like: How to Improve the Performance of a Java Application
While this church mouse approach helps avoid some common application issues like memory leaks, it also, unfortunately, results in massive overhead associated with restarting your application for every single request. For a simple HTTP request, for example, a PHP application requires significant loading on behalf of the framework in use (i.e. Symfony, Laravel, etc.) in addition to the time and computational power used up establishing database connections and processing logic. The worse part? After one simple request, it all has to be destroyed to start again from scratch.
On top of all that, PHP does not provide an easy way for developers to integrate alternative methods for communicating and processing into their applications. Even consuming simple data from message broker software like RabbitMQ typically requires a sizeable library or extension. Plus you have to configure the supervisor to ensure that your PHP scripts don’t die or crontab at the top to restart scripts in case of an external error.
These common complaints are why many developers have called PHP a dying programming language (despite almost 80% of the world’s top 10M websites using PHP as their primary code). While many other languages have solved similar issues by dedicating part of their infrastructure logic to application servers (i.e. you’ll be hard-pressed to find a Java engineer who does not employ TomCat or its analog), when it comes to PHP, there has not been a similar solution...until now.
Meet Roadrunner, a High-Performance PHP Application Server, Load-Balancer and Process Manager Written in Golang
Imagine building your PHP application once and then reusing it for multiple requests without having to tear it down. RoadRunner makes this possible.
RoadRunner builds using Golang which creates massive room for simple extensions and project-specific customizations. It allows you to integrate any existing Golang library with PHP and communicates with your application over PSR-7 standard. Compatible with all major frameworks available today, RoadRunner is MIT-licensed and has already been downloaded from Github 12.000 times.
This powerful application server runs your application in a daemonized mode which significantly improves performance by offloading some of the burdens on the framework. Public benchmarks demonstrate 10-20 times higher performance with RoadRunner than with PHP-FPM.
RoadRunner also includes a lot of instruments to ensure that your application runs safely, such as memory leak controls and TTL controls. It can serve static files without the presence of Nginx, therefore, simplifying the creation of Docker containers.
On top of all of that, RoadRunner provides a number of extensions. For example, with RoadRunner you can serve the GRPC API for a PHP application to simplify integration with other technologies. The queue (https://github.com/spiral/jobs) extension handles all the logic of working with queue brokers, such as durable reconnects and prefetch control making it possible to perform a 20-line integration with brokers like RabbitMQ, Amazon SQS, Beanstalk or run async PHP in server memory.
With RoadRunner, Golang effectively does all the “heavy lifting” when it comes to starting, stopping, and managing your PHP application as well as controlling how many worker processes can run at a given time. Using another open-source solution, Goridge, you can bridge the Golang and PHP sides of your application and pass PSR7 Request and Responses faster and more efficiently than ever too.
RoadRunner accelerates development, improves application efficiency and performance, and has the power to overturn many of the assumptions people have of PHP.
Opinions expressed by DZone contributors are their own.