On Cloud Platform environments, you can configure a limited subset of PHP settings to improve Drupal application performance or remediate certain errors.
To change an environment’s PHP settings:
- 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.
- Use the PHP section to configure PHP for your application’s needs. Click one of the following available PHP settings for information about the item, including configuration options.
Runtime Settings
Advanced PHP settings
- Click Save.
Limits on memory configurations by subscription type
Depending on your subscription type, Cloud Platform may prohibit you from making certain changes to memory limits. 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
Your Drupal application runs on the PHP programming language.
You can configure the version of PHP used by your application for each environment. When viewing your applications, the Cloud Platform user interface displays the version of PHP installed on your production environment on your application’s card.
Which PHP version to use
Cloud Platform offers the following versions of PHP for your applications’ use:
- 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: For use with websites running 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 haven’t yet 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.
As a general principle, use the latest available version of PHP. Each new version of PHP includes both enhancements and bug fixes that can improve the performance and security of your Drupal application. However, you may be using custom or contributed Drupal modules that depend on an earlier version of PHP. Whenever you change your PHP version, do so first 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 your PHP code should work fine on the PHP versions that Cloud Platform offer. However, some of your code may work on one version of PHP, but not on another version. If you plan on switching to a different version of PHP, do so first on your Dev or Stage environment and test it before changing your production environment.
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. For most applications, you should leave them at their default settings. You can change them if you’re advised to do so by Acquia Support, or if you are confident that you know what you are doing.
Configuring any of the following values involves either using a setting’s slider to change the value in its field, or by directly entering values in the field. To return any of the following settings to their original value, click the Reset link by the value, and then click Save.
Configuring max execution time
By modifying the Max execution time field, you can configure the maximum amount of time 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 PHP maximum 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.
The danger of allowing longer PHP maximum execution times is that individual page loads can occupy process slots for long periods of time, blocking other processes from using them.
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 running on Acquia’s Cloud Classic infrastructure, increasing your PHP memory limit beyond 128 MB on any one environment may reduce the number of PHP processes. These PHP processes handle requests across all environments sharing 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, you’ll see an entry in the PHP error log stating a process ran out of memory.
If your application stops working and there is an Out of Memory error in the PHP error log, increase the PHP memory in small increments until your application is working 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, you won’t be able to run more than a few PHP processes on a machine without running out of RAM.
Configuring OPcache size
Using an OPcache improves PHP performance. 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’re run, eliminating the time needed for reinterpretation on later requests.
Acquia’s test results show using an opcode cache offers a three-fold to four-fold increase in performance. To improve application performance, Cloud Platform implements opcode caching by default on all applications, using OPcache.
All processes share the PHP OPcache, and its default size is 96 MB. Memory allocated to the PHP OPcache isn’t available for processes that are handling requests on your infrastructure, so there is a cost to making the cache size too large.
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’s 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 does not recommend setting your environment’s max_input_vars
value higher than 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.
You may want to change this value if your application includes large or complex form inputs and you are getting PHP warnings about input variables exceeding the limit. The default value is 1000. The highest value you can set in the Cloud Platform interface is 2500. If your application requires a greater value (or if you have a Platform Enterprise application), you can file a ticket for Acquia to set a greater value. Greater values can lead to security vulnerabilities, so Acquia recommends you don’t set the value to a number greater than 5000. As an alternative, you should consider redesigning your application’s forms to be 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.