Jelastic Auto Configurations for PHP App Servers

Jelastic dynamic resources organization complements the basic PHP one in order to bring the maximum efficiency for PHP integration into the Cloud. Upon changing the amount of allocated resources for your environment (i.e. cloudlet amount), Jelastic will automatically adjust the corresponding PHP module’s directives to suit the new conditions. Herewith, you still have the possibility to configure these autoscalable 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, though 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:


Besides that, you can learn How the Auto Configuration Works or, if you want to redefine the values for the described below parameters with your own, proceed to the How to Disable the Automatic Jelastic Optimization section of this guide.

Apache Auto Adjustable Settings

Dynamic requests handling in Apache is implemented with the help of the prefork Multi-Processing Module (MPM), which helps to fully reveal server potential at the Cloud. The MPM directives used are stored in the main Apache configuration file - httpd.conf, which 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.

    If you’d like to state your custom value, note: The amount of child processes depends on the load and is not bounded to their initial number, set by the current parameter. So there is usually little reason to adjust it.
  • 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.  

    If you’d like to state your custom value, note: stating ServerLimit to a value, that is much higher than necessary, will cause allocation of the extra, unused shared memory, while stating it too low won’t reveal the full server performance potential.
  • 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.

    If you’d like to state your custom value, note: MaxClients 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 for the number of clients’ processes you’ve stated. Pay attention, that this value is limited by a ServerLimit parameter, and if both of them are set higher than the system can handle, your Apache server may become unstable.

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 (based on Jelastic 3.1 version) for a few main environment RAM levels:

DirectiveDynamic cloudlets (RAM)
8 (1 Gb)16 (2 Gb)32 (4 Gb)
ServerLimit122551
MaxClients122551
StartServers102040

You may also be interested in How the Auto Configuration Works or how to Disable the Automatic Jelastic Optimization, in order to set your custom values for these directives.

NGINX-PHP Auto Adjustable Settings

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).

    If you’d like to state your custom value, note: This directive is mandatory. Its value should be big enough to handle such amounts of simultaneous requests as you expect to receive, and small enough to ensure that there is enough RAM for the number of child processes you’ve stated, otherwise the server may become unstable.
  • 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

    If you’d like to state your custom value, note: The actual amount of child processes depends on the load and is not bounded to their initial number, set by the current parameter. So there is usually little reason to adjust it.
  • 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 become greater than the pm.max_spare_servers value, then it will be killed).

    If you’d like to state your custom value, note: This directive is used only when the pm mode is set to dynamic and is mandatory. It acts in a bundle with the similar pm.min_spare_servers directive, which is located just up the file and sets the minimum number of child processes in the idle state. So if the amount of spare processes become less than this number, then some new ones will be created.

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 (based on Jelastic 3.1 version) for a few main environment RAM levels:

DirectiveDynamic cloudlets (RAM)
8 (1 Gb)16 (2 Gb)32 (4 Gb)
pm.max_children122550
pm.start_servers92040
pm.max_spare_server92040

Now, if you are interested, you can find an example on How It Works or a way to Disable the Automatic Jelastic Optimization, in order to set your custom values for these directives.

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 another 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.

Disable Automatic Jelastic Optimization

To state your custom values for the automatically configured directives described above, first you’ll need to disable the automatic Jelastic optimization, in order not to lose the performed changes during the update.

Note that inappropriate directive values may cause your server instability, so before proceeding, please see the recommended settings within the corresponding guide sections (for  Apache or NGINX-PHP). Remember that you are doing this at your own risk.

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 your application server. Just don’t forget to Save the file in order to apply the new configurations.