Information for: DEVELOPERS   PARTNERS

Configuring PHP settings

On Acquia 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, complete the following steps:

  1. Sign in to the Cloud Platform user interface and select the application you want to configure.

  2. Select the environment that you want to configure, click Actions, and select Configure Environment. Alternatively, click Configuration in the left navigation pane.

    Location of the Configure option on the Cloud Platform interface

  3. 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
  4. Click Save.

Limits on memory configurations by subscription type

Depending on your subscription type, Acquia 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:

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 Acquia Cloud Platform user interface displays the version of PHP installed on your production environment on your application’s card.

Important

If you update the PHP version through the Acquia Cloud Platform user interface in Cloud Classic, the system might take some time (~ 30 minutes) for the change to take effect. For more information, see PHP Version change taking a long time.

Which PHP version to use

Acquia Cloud Platform offers the following versions of PHP for your applications’ use:

  • Acquia PHP 8: For use with Drupal 8 and greater websites. Some libraries available in Acquia PHP 7.4 may not yet be available in PHP 8 if they haven’t yet been updated by the PHP community for PHP 8 compatibility.

    Note

    Currently, PHP 8 is incompatible with Site Factory.

  • Acquia PHP 7.4 (default): For use with Drupal 8 and greater websites. 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. New environments will use PHP 7.4 by default.

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

Changes from PHP 7.4 to PHP 8.0

  • The string.strip_tags filter is removed with PHP 8.0.
  • track_erros was deprecated in PHP 7.2 and removed in PHP 8.0.
  • mbstring.func_overload is removed from PHP 8.0.
  • The assert.quiet_eval ini directive and the ASSERT_QUIET_EVAL constant are removed.

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.

Diagnosing and fixing PHP errors

If you believe your application is experiencing PHP errors, see PHP Error logs. To correct PHP memory issues, see Finding/Resolving Memory Related PHP errors in Cloud Platform.

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 doesn’t complete in in the max 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 (300 seconds, or 5 minutes) is adequate for most Drupal applications on Acquia 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 Acquia 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.

Memory limits greater than 1024 MB per process on the Acquia Cloud Classic infrastructure

Subscribers with Cloud Platform Plus, Cloud Platform Premium, and Cloud Platform Elite subscriptions can buy the Acquia Cloud Platform Performance Boost add-on for applications needing a PHP memory limit greater than 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, Acquia 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 Acquia Cloud Classic: The default setting is 8 MB.
  • For Acquia Cloud Next: The default setting is 32 MB. If you use the Acquia Cloud Platform user interface, you can set the minimum value to 8 and the maximum value to 32.

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.

To set the Interned Strings buffer greater than 32 MB, contact Acquia Support.

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 8 and Drupal 9 make more use of the APCu cache as a local, short-term cache than earlier versions of Drupal did.

The maximum setting is 1024 MB.

Sum of OPcache size and APCu size in the Cloud Classic infrastructure

OPcache size and APCu size are dependent on the upper memory bound of the environment. The sum of these values cannot exceed 1024 MB.

Subscribers with Cloud Platform Plus, Cloud Platform Premium, and Cloud Platform Elite subscriptions can buy the Acquia Cloud Platform Performance Boost add-on for applications that need the sum of OPcache size and APCu size to be greater than 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 Acquia 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 Sendmail path

Important

EOL notice! Legacy Email support will reach end-of-life on February 1, 2022. For more information, see Legacy Email Retirement FAQ. To begin configuring Platform Email Service for your application, see Configuring a domain.

You can configure the path used by Sendmail for email originating from your application. For more information, see About email in Cloud Platform applications.

Configuring the Memcache memory limit

Note

This feature is available only on Acquia Cloud Next.

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 Acquia Cloud Next technologies.

The default setting for the Memcache memory is adequate for most Drupal applications on Acquia 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.

Note

Memory limits greater than 2048 MB

Acquia doesn’t recommend exceeding 2048 MB of Memcache memory allocation, as only the largest and most complex applications on Acquia Cloud Platform will see performance improvements with that much memory reserved for Memcached. Typically, this value or a higher value is only necessary for Drupal multi-site deployments with 100 sites or more.

Higher Memcache memory allocations may result in overages fees on subscriptions with explicit Cloud Capacity Unit limits or subscriptions with Cloud Capacity Unit utilization beyond Acquia’s publish Fair Use guidelines.