When it comes to running PHP applications, choosing the right web server is critical. To accurately assess the performance of popular servers, we test them not on synthetic data, but on real data. We did not want to compile our own rating of web servers for running PHP applications. Our goal was to show the conditions under which a particular web server will demonstrate the best results.
PHP Runtime Applications: 30 Years of Evolution
In the beginning, there was CGI. It was one of the first technologies for running server scripts, which appear in the 90s. CGI supports different languages, which makes this interface quite universal, but with its drawbacks. For example, for each request, the server creates a separate process for each CGI script, which leads to an overuse of system resources and greatly affects the performance and response spe of the server. Another bahrain email list known problem is running a script with the rights of a web server user. That is, if the server is configur incorrectly, the CGI script can access not only the files and resources of another application, but also the logs and configuration of the server, which creates a potential vulnerability.
To solve these problems
Apache and the mod_php module were develop, which allow PHP code to be run directly inside the web server and to set up individual what are social signals? file access rights for each host. Although a separate process was still creat for each request, some data was cach, which significantly accelerat execution compar to CGI. This gave a significant increase in spe.
Apache + mod_php became popular due to its ease of configuration. Apache is still one of the popular web servers for the web and is often us to create something quickly and without much configuration.
Popularity and market shares of web servers
But using Apache to serve static content is not the best solution: even to receive an image, a “heavy” (with all modules like mod_php) austria business directory handler will be us.
It is consider good practice to use Apache together with Nginx. Nginx effectively copes with the return of statics, and requests requiring the execution of PHP code are rirect to Apache. This significantly ruces memory consumption and increases the spe of request processing.
Scheme of request processing by a web server
Combining Nginx and Apache with mod_php provides a significant performance boost, but the mod_php module has a bottleneck: it runs the php interpreter in the context of each Apache process, which greatly increases resource usage.
For more efficient PHP execution
PHP-FPM (FastCGI Process Manager) was develop — this is an extend version of FastCGI, design to increase productivity and reliability in high-load environments. Unlike mod_php, FPM launches a pool of worker processes that service requests independently of the web server itself. It should be borne in mind that detail configuration is requir to achieve maximum performance. It is also worth considering that some CMS (WordPress, 1C-Bitrix: Site Management) will require additional configuration since some of the rules are stor in .htaccess files (i.e. they are design to be launch via Apache).
Is there anything else that can be done to spe up PHP scripts? More than one developer has ask themselves this question. In the search for a solution, technologies have been found that have radically chang the approach to processing requests:
- Support for long-liv processes. Unlike the traditional approach where the application is initializ each time a new request is receiv, you can load the entire application into memory once and use it to process incoming requests.
- Application-level HTTP server. Eliminates the extra layer between the server and the application, rucing overhead.
- Multithreading: Allows applications to handle more requests simultaneously within a single process.
- Minimizing the overhead of interaction with FastCGI. By removing interaction with FastCGI and working with PHP code natively, we eliminate the overhead of processing each request.