Spiral can be used with a traditional Nginx/PHP-FPM setup, where Nginx acts as the web server and PHP-FPM processes incoming requests and initializes the application. However, this can be resource-intensive as it requires CPU and memory resources to complete with every incoming request.
To improve the performance of Spiral application, an alternative solution is to use application server RoadRunner.
RoadRunner is a high-performance application server designed to handle a wide range of request types, including HTTP, gRPC, TCP, Queue Job consuming, and Temporal. It operates by running workers only once when it is initiated and then directing requests to a dispatcher based on their type. This means that each worker is isolated and works independently, following a "share nothing" approach where resources are not shared between workers.
The approach of running application is similar to other languages like Java, C#, etc.
This allows developers to write code in a way that is familiar to them and allows workers to be horizontally scaled, improving resource utilization and increasing the capacity to handle incoming requests.
Using RoadRunner can significantly improve the speed and efficiency by eliminating the need for the application to go through the bootstrapping process repeatedly. This can save on CPU and memory resources and reduce response time.
Another cool thing is that it allows developers to be a bit more flexible with how they bootstrap the application. For example, they can load configs or routes from various sources like attributes or files without having to worry about caching them. This can make it easier to modify and update the application as needed.