The Jelastic Platform is characterized with one of the best dynamic resources orchestration for cloud services, and its benefits have already been described many times (for example, in this article you can see how this applies to pricing). Though this mechanism is highly efficient by itself, but being combined with and tightly complemented by the basic application servers’ memory organization, it can bring even more profit.
Thus today we’d like to reveal how this integral Jelastic feature helps to optimize the productivity of PHP applications with the dynamically changing amount of resources (made possible due to the versatile combination of the automatic horizontal and vertical scaling). In the most common case, it works in the following manner: when the number of allocated resources (i.e. cloudlets) for your environment is changed, Jelastic instantly adjusts the corresponding server’s directives to suit the new conditions. Below, we’ll show you this in detail through covering the following questions:
- which PHP settings are affected?
- how does the optimization work?
- how can the Jelastic Auto Configuration be disabled?
Now let’s discover this step-by-step!
Auto Adjustable Settings
The first thing you need to learn is the parameters, that are automatically configured by Jelastic - this will give you a better understanding. As our platform provides a choice of two application servers for your PHP apps’ hosting, we’ll consider the appropriate settings for both of them, starting with Apache.
Dynamic requests’ handling in Apache is implemented using the prefork Multi-Processing Module (MPM), which helps to fully reveal the server potential at the Cloud. The used MPM directives are stored in the main Apache configuration file - httpd.conf, that is located in the conf folder.
Here is a complete list of parameters, which are configured by Jelastic automatically, based on the amount of allocated resources:
- StartServers parameter sets the number of child processes, that should be initiated at a server’s startup.
- ServerLimit - this parameter sets the maximum possible value of the MaxClients directive (see its description below) for the lifetime of the server. If you try to state the MaxClients parameter higher than this limit, it will be dropped down to the ServerLimit value.
- MaxClients directive sets the maximum number of child processes, that can be launched simultaneously for serving the requests. Any connection attempt over the MaxClients limit will normally be queued, for being consequently picked up and processed, once one of the child processes has finished handling another request.
Within the Jelastic implementation, values for the above described settings are calculated automatically, based on the maximum amount of available resources (dynamic cloudlets). Below, you can find the table with these parameters’ default values for a few main environment RAM levels:
Now, let’s learn about the similar NGINX-PHP directives.
Handling of requests in the NGINX-PHP application server is managed by FastCGI Process Manager (FPM). Its main configuration file is php-fpm.conf, located inside the etc folder.
FPM can work in either dynamic or static mode, enabled according to the pm directive’s value. By default, it is equal to dynamic, which allows Jelastic to configure other related parameters due to the amount of allocated environment resources:
- pm.max_children - it has different meanings for the static and dynamic process manager state. In the first case, it defines the number of child processes to be created at the server’s start (which won’t be changed anyway), and in the second one - the maximum number of child processes, that are allowed to be created (as their amount will subsequently scale up, if required).
- pm.start_servers - states the number of child processes, created on server’s startup. It is used only with the dynamic pm value, since for the static process manager mode, all of the children processes (where the amount is stated within the pm.max_children parameter) are loaded at once. If this directive is not set, the default value will be used, which is calculated due to the next formula (the appropriate values can be found within the same configuration file):
pm.min_spare_servers + (pm.max_spare_servers - pm.min_spare_servers) / 2
- pm.max_spare_servers - sets the desired maximum number of idle (waiting) server processes. Such processes can quickly react on the received requests and process them almost immediately, skipping the regularly needed time of initiating a new operation. After the request is handled, the appropriate child process returns to the waiting state (nevertheless, if the overall number of idle processes becomes greater than the pm.max_spare_servers value, then it will be killed).
Within the Jelastic implementation, values for these settings are calculated automatically, based on the maximum amount of available resources (dynamic cloudlets). Below you can find the table with these parameters’ default values for a few main environment RAM levels:
Great! Now, when you know the role of each of the directives used in the PHP dynamic memory organization, we can proceed to examination of the Jelastic Auto Configuration workflow.
How the PHP Auto Configuration Works
You can check how the abovementioned parameters are changed depending on the amount of resources you set. The process is almost the same for both application servers, so let’s consider it on the example of Apache:
1. Create a new PHP environment with the Apache application server inside (if you don’t have one).
Then, click the Config button for this node and find the conf > httpd.conf file through the opened tab.
Scroll down approximately to the 100th line and remember the values of the directives, used for Jelastic automatic optimization (circled in the image above), and the maximum scaling limit for the server (i.e. dynamic cloudlets number, can be seen in the Usage dashboard column, 16 in our case).
2. Now, with the help of the same-named button, access the Change environment topology wizard and set some other amount of resources for your Apache server (in our case we increased it to 32 cloudlets). Then repeat the operations from the first point (i.e. find and compare the directive values you got with the ones from the previous step).
As a result of this comparison, we can conclude that parameter values increased automatically simply due to a higher amount of available resources allocated. Similar to this, upon stating a lower amount of resources, these parameters’ values will be reduced.
That’s how the automatic optimization works! However, if you are an experienced user and would like to change these parameters for your custom needs, Jelastic gives you such an opportunity.
Disable Automatic Jelastic Optimization
To state your custom values for the automatically configured directives described above, at first you’ll need to disable the automatic Jelastic optimization, in order not to lose the performed changes during the update.
The process is almost the same for both PHP servers - you just need to remove the line with the Jelastic optimization mark at the beginning of the corresponding configuration file:
- for Apache: # Jelastic autoconfiguration mark - inside the conf > httpd.conf file
- for NGINX-PHP: ; Jelastic autoconfiguration mark - inside the etc > php-fpm.conf file
After the corresponding string is deleted, the auto configurable parameters’ values won’t be reset by the Jelastic optimization mechanism, thus your custom ones can be stated and used by the application server. Just don’t forget to Save the file in order to apply the new configurations.
That’s all for today! If you still have questions or would like to leave a suggestion - feel free to post it to the comments below. You can also examine all of the benefits that Jelastic Cloud smart memory organization delivers by signing up for a free two-week trial.