The platform dynamic resources organization complements the basic PHP one to bring the maximum efficiency for PHP integration into the PaaS. Upon changing the amount of allocated resources for your environment (i.e. cloudlets count), the platform automatically adjusts the appropriate PHP directives to fit the new conditions. However, you can still configure parameters manually within your server’s configuration file.
The type of basic requests' handling and dispatching system varies for different PHP application servers, so the directives they use are different too. However, the functionality of such parameters could be similar. To learn more about these directives for a particular application server, navigate to the corresponding section below:
Dynamic requests handling in Apache PHP is implemented with the help of the prefork Multi-Processing Module (MPM), which helps to reveal full server potential. The MPM directives are listed in the main Apache /etc/httpd/conf/httpd.conf configuration file.
Here is a complete list of parameters, which the platform configures for the prefork module:
Based on the allocated resources (i.e. a number of dynamic cloudlets reserved for the Apache PHP server) and capacity of the CPU provided by your particular hosting provider, the platform automatically adjusts the ServerLimit and MaxRequestWorkers parameters:
MaxRequestWorkers = ServerLimit = min( {containerRam} / 30MiB, {coresCount} * 5 )
Due to this statement, both directives are stated equal to the lower value between:
Note: If you’d like to state your custom value for these directives, be aware that incorrect values can cause your Apache PHP server instability:
- if ServerLimit is much higher than necessary, the unused shared memory is allocated; while stating parameter too low won’t reveal the full server performance potential
- MaxRequestWorkers should be big enough to handle as many simultaneous requests as you expect to receive and small enough to ensure that there is enough RAM
You may also be interested in How the Auto Configuration Works or how to Disable the Automatic Optimization to set your custom values for these directives.
Request handling in the NGINX PHP application server is managed by FastCGI Process Manager (FPM), which can be configured via the /etc/php-fpm.conf file. It is automatically added to the favorites list in the container file manager for quick access:
The FPM works in the ondemand mode (the pm directive) by default. It spawns new processes when needed (i.e. on demand) and removes idle ones. The only additional parameters for this mode are:
Tip: The exact value depends on the capacity of the CPU provided by your particular hosting provider and the number of allocated cloudlets for your container. In such a way, cloudlets count enlargement results in the automatic growth of the pm.max_children parameter. This directive can be defined explicitly without disabling the automatic optimization through the appropriate PHPFPM_MAX_CHILDREN variable.
If needed, you can Disable the Automatic Optimization to change the FPM mode and adjust other directives (be aware that incorrect values can cause your NGINX PHP server instability).
Also, to gain advanced performance, the PHP FPM listener utilizes the UNIX domain socket instead of the common TCP one. Such a solution is better suited for the communications within the same host, allowing to skip some checks and operations (like routing).
You can check how the parameters mentioned above are changed based on the allocated resources. We’ll consider it on the Apache PHP server example:
Then, click the Config button for this node and find the prefork module configs in the /etc/httpd/conf/httpd.conf file.
Remember the values of the directives for the current cloudlets number (16 in our case).
As you can see, the directive values increased automatically due to a higher amount of available resources allocated, so the automatic optimization works. Similar to this, upon lowering the cloudlets count, these parameters' values will be reduced.
To state your custom values instead of the automatically configured directives, you need to disable the automatic optimization. Otherwise, your custom changes will be reverted during the container restart/update.
Note: Inappropriate directive values may cause your server instability, so it is not recommended to apply any manual changes unless you know exactly what you are doing.
If you want to manually change any of the auto-configured settings, you need to set the JELASTIC_AUTOCONFIG environment variable to false.
On the old containers, you just need to remove the line with the optimization mark at the beginning of the corresponding configuration file:
Apache PHP - “# Jelastic autoconfiguration mark” within the /etc/httpd/conf/httpd.conf file
After the corresponding string is deleted, the parameters' values won’t be auto-configured by the platform optimization mechanism so that you can state your custom parameters. Don’t forget to Save the file to apply the new configurations.