This document provides instructions on how to configure a limited subset of PHP settings on Cloud Platform environments in order to improve Drupal application performance or remediate certain errors.
To change the PHP settings on an environment:
- Sign in to the Cloud Platform user interface and select the application you want to configure.
Select the environment that you want to configure, click Actions, and select Configure Environment. Alternatively, click Configuration in the left navigation pane.
- Configure the settings in the PHP section to meet the needs of your application. Click one of the following available PHP settings for information about the item, including configuration options.
Runtime Settings- Configuring the PHP version: If the system updates the PHP default version, you can update the settings in the Cloud Platform user interface.
Advanced PHP settings
- Click Save.
Limits on memory configurations by subscription type
Cloud Platform may prohibit certain changes to memory limits, depending on your subscription type. Here is a list of Acquia subscription types and their memory limits:
- Cloud Platform Plus, Cloud Platform Premium, and Cloud Platform Elite: If your application needs any of the following memory limits on the Acquia Cloud Classic infrastructure, contact your Account Manager to buy the Acquia Cloud Platform Performance Boost add-on:
- PHP memory limit greater than 512 MB per process
- Memcached memory limit greater than 128 MB
- OPcache size and APCu size greater than 512 MB
- Varnish cache hit rate less than 80%
Configuring the PHP version
The Drupal application runs on the PHP programming language.
Configure the version of PHP that the application uses for each environment. To see the version of PHP that is installed on the production environment, go to the Cloud Platform user interface. For more information about how to view applications, visit Managing applications with the Cloud Platform interface.
Which PHP version to use
Cloud Platform offers the following versions of PHP:
- Acquia PHP 8.3 (default): Some libraries that are available in Acquia PHP 7.4 might be currently unavailable in PHP 8.3 if the PHP community has not updated them for PHP 8.3 compatibility.
- Acquia PHP 8.2: Some libraries that are available in Acquia PHP 7.4 might be currently unavailable in PHP 8.2 if the PHP community has not updated them for PHP 8.2 compatibility.
- Acquia PHP 8.1: Use with websites that run the current Drupal version. Some libraries that are available in Acquia PHP 7.4 might be currently unavailable in PHP 8.1 if the PHP community has not updated them for PHP 8.1 compatibility.
- Acquia PHP 7.4: For older versions of Drupal, PHP 7.4 is available. If you require PHP 7.4 beyond its end of life, see PHP 7.4 LTS Program. Some libraries available in Acquia PHP 7.3 may not yet be available in PHP 7.4 if they have not been updated by the PHP community for PHP 7.4 compatibility. This option is available only if you avail the paid program for PHP 7.4 Long Term Support (LTS). For more information, see PHP 7.4 Long Term Support (LTS) Program.
Use the latest available version of PHP if possible. Each new version of PHP includes enhancements and bug fixes that can improve performance and security. Some installations use custom or contributed Drupal modules that depend on an earlier version of PHP. When you update or change your PHP version, first update it on your Development or Stage environment, not on your Production environment, and test it to ensure that there are no compatibility issues.
Working with different PHP versions on different environments
Most of the PHP code works properly on the PHP versions that Cloud Platform offers. However, some code may work on one version of PHP, but not on another version. When you update or change your PHP version, first update it on your Development or Stage environment, not on your Production environment, and test it to ensure that there are no compatibility issues.
Comparison of PHP 7.4 with PHP 8.0 and later
Parameters | Available in PHP 7.4 | Available in PHP 8.0 and later |
---|---|---|
string.strip_tags | ✓ | 𐄂 |
track_errors | ✓ (deprecated) | 𐄂 |
mbstring.func_overload | ✓ | 𐄂 |
The assert.quiet_eval ini directive and the ASSERT_QUIET_EVAL constant | ✓ | 𐄂 |
Advanced PHP settings
The following settings are for advanced users. Leave the default settings on most applications. You can change them if you are advised to do so by Acquia Support, or if you are confident in the changes.
To configure any of the following values, you can use the slider on the setting to change the value in its field, or enter the values directly in the field. To return any of these settings to their original value, click Reset > Save.
Configuring max execution time
Modify PHP max_execution_time
to configure the maximum amount of time that any PHP process can take. If a PHP process does not get completed in the maximum execution time, the process fails and sends an error. The time limit helps to prevent PHP processes from becoming stuck and unavailable to serve new requests.
The default setting for max_execution_time
, that is 300 seconds or 5 minutes, is adequate for most Drupal applications on Cloud Platform. You can change the setting if necessary.
A max_execution_time
of 120 seconds or less should suffice for most cases. However, it is important to monitor logs and adjust this setting as necessary to achieve optimal performance.
Manual changes to high values for the max_execution_time
setting may lead to several issues, including:
High resource consumption during simultaneous long-running web processes.
Decreased capacity to handle new requests.
I/O blocking of PHP workers when code relies on slow-responding APIs or other external services.
Difficulty in detecting, debugging, and correcting issues in long-running code.
Some ways to mitigate these risks and enhance the availability and performance of your application are:
Set a lower
max_execution_time
.Optimize your code.
Handle long tasks asynchronously or use the Drupal Batch API to divide them into smaller tasks.
Configuring PHP memory limit
The PHP memory limit is the maximum amount of RAM (random access memory) that a single PHP process can use. The memory used by the MySQL client counts against the PHP memory limit. The default setting for the PHP memory limit is 128 MB per process.
The default setting for PHP memory is adequate for most Drupal applications on Cloud Platform. You can change the setting if necessary. On environments that run on the Cloud Classic infrastructure, you may reduce the number of PHP processes by increasing your PHP memory limit beyond 128 MB on any one environment. These PHP processes handle requests across all environments that share the same infrastructure.
Depending on the complexity of certain pages on your site, you may find that the PHP memory limit on your environment is insufficient for those pages to load properly. When this happens, an entry in the PHP error log states that a process ran out of memory.
If the application stops working and there is an Out of Memory error in the PHP error log, increase the PHP memory in small increments until the application starts to work again, and then add a safety margin of additional memory. The maximum setting is 1024 MB per process.
If the Out of Memory error was caused by a one-time set of conditions (for example, enabling a large set of modules), reduce the PHP memory setting after the event. If you leave the PHP memory setting too high, the RAM will become full when multiple PHP processes on a machine run simultaneously.
Configuring OPcache size
Improve PHP performance with an OPcache. Since PHP is an interpreted programming language, each time a PHP script is called, it has to be reinterpreted. An opcode cache saves these scripts as machine code in memory the first time they are run. This eliminates the time needed for reinterpretation on later requests.
Acquia test results show that an opcode cache offers a 3 to 4 times increase in performance. To improve application performance, Cloud Platform uses the opcode cache by default on all applications with OPcache.
All processes share the PHP OPcache, and its default size is 96 MB. Avoid large cache sizes because memory allocated to the PHP OPcache is not available for processes that handle requests on your infrastructure.
The minimum setting is 96 MB and the maximum setting is 512 MB.
OPcache interned strings buffer
The Interned Strings buffer is the amount of the PHP OPcache memory that is reserved for storing strings in OPcache. The amount of memory allocated to the Interned Strings Buffer will reduce the total amount of memory available for PHP OPcache.
- For Cloud Classic: The default setting is 8 MB and the maximum value is 32 MB.
- For Cloud Next: The default setting is 24 MB and the maximum value is 32 MB.
If your OPcache is set to 96, this leaves 88 MB for normal OPcache usage. If you must increase the interned strings buffer over 16 MB, Acquia recommends increasing the OPcache by the same amount. For more information about resolving the errors when PHP OPcache or OPcache interned strings buffer is set too low, see Understanding and Resolving PHP OPcache and OPcache Interned Strings buffer errors.
To set the Interned Strings buffer greater than 32 MB, create a Support ticket.
APCu size
The APC User Cache (APCu) size sets the amount of memory allocated to APC User APCu. This is a smaller cache than PHP OPcache, and most applications will run well with the default value (32 MB). Drupal makes more use of the APCu cache as a local, short-term cache than earlier versions of Drupal did.
The maximum setting is 1024 MB.
Maximum input variables
You can set the maximum number of input variables to accept. The limit (the PHP max_input_vars
setting) is applied separately to $_GET
, $_POST
, and $_COOKIE
inputs.
Acquia recommends that the value of the max_input_vars
for the environment should not exceed 2500. Larger values are considered a risk to site performance and security, and should be avoided whenever possible. The default value is 1000.
Acquia Cloud Enterprise subscribers can edit the maximum input variable PHP setting.
Some cases may require a value higher than 2500. File a ticket request for Acquia to set a greater value. Some reasons this may be needed are:
Your application includes large or complex form inputs.
You get PHP warnings about input variables that exceed the limit.
Your application requires a greater value.
You have a Platform Enterprise application.
Greater values can lead to security vulnerabilities, so Acquia recommends that you do not set the value to a number greater than 5000. Consider a redesign of the forms on your application to make them smaller and less complex.
Maximum size of POST request
You can set the maximum acceptable size of a POST request (the PHP post_max_size
setting). This value affects the maximum size of file uploads on your application and should be smaller than the PHP memory limit. The default value is 256 MB. Larger sized POSTs are more susceptible to failure.
Configuring the Memcache memory limit
The Memcache memory limit is the maximum amount of RAM (random access memory) that Memcached can use on an environment. The default setting for the Memcache memory limit is 64 MB per environment. This value can only be configured per environment for environments running on Cloud Next technologies.
The default setting for the Memcache memory is adequate for most Drupal applications on Cloud Platform. If necessary, you can change the setting to improve the site performance. Environments with insufficient memory allocated to Memcached will see more frequent evictions of data stored in this service.