Page 1 of 1

Server Request Processing Scheme.png

Posted: Sun Jan 19, 2025 4:24 am
by hasibaakterss3309
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) handler will be used.

It is considered 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 redirected to Apache. This significantly reduces memory consumption and increases the speed of request processing.



Scheme of request processing by a web server.

Combining Nginx and Apache with mod_php north korea company email list 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 developed — this is an extended version of FastCGI, designed 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 detailed configuration is required 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 stored in .htaccess files (i.e. they are designed to be launched via Apache).

Is there anything else that can be done to speed up PHP scripts? More than one developer has asked themselves this question. In the search for a solution, technologies have been found that have radically changed the approach to processing requests:

Support for long-lived processes. Unlike the traditional approach where the application is initialized each time a new request is received, 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, reducing 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.

Let's look at the pros and cons of some ways to launch PHP applications:
1. Apache + mod_php
Created by: Apache Software Foundation. Written in C.

Pros:

Easy to configure. mod_php is included in the standard Apache build.

Stability. The solution is time-tested and has a large database of ready-made projects.

Cons:

Resource-intensive. The module is loaded inside each Apache process, which greatly affects performance.

Large increase in resource consumption under high loads.

Lack of flexibility. Does not allow fine-tuning the configuration for each virtual host or sharing resources between processes.