PHP

PHP (Hypertext Preprocessor) is an open-source scripting language that is especially suited for web development. It runs on the server side, meaning it processes code on the web server before sending it to the client (browser). WordPress is built on PHP; therefore, it’s essential for WordPress sites. PHP enables your WordPress site to:

  • Generate dynamic content and display it on a website in real-time.
  • Interact with your database, allowing it to fetch and store data.
  • Handle forms and process user input making WordPress sites more interactive.
  • Use themes and plugins to extend WordPress’s core capabilities.
  • Improve performance by ensuring much of the heavy lifting happens on the web server before the content reaches the user’s browser.

How PHP is processed

When a visitor visits an uncached page or performs an action on a page (e.g., adding something to a cart, submitting a form, etc.), the following process occurs:

  1. The web server (Nginx here at Kinsta) receives that request.
  2. Nginx passes the request to PHP, which is assigned to an available PHP thread.
  3. The PHP thread executes the PHP script (e.g., fetching data from the database or processing forms).
  4. While processing, the PHP thread uses a portion of the server’s memory up to the PHP memory limit set in Kinsta.
  5. If there are multiple concurrent visitors, each request is assigned to a different PHP thread. If all threads are busy, additional requests wait until a thread becomes available.
  6. PHP then generates an HTML page using your theme’s PHP files (and any plugin files, if applicable).
  7. PHP hands the rendered HTML page back to the web server.
  8. The page is served to the visitor.

If your site does not use caching or is not optimized, PHP threads may be busy for longer, which can degrade performance and lead to timeouts or 503 and 504 errors when visitors access your site. For information about how to check the PHP performance and how to optimize your PHP threads, refer to PHP performance.

PHP threads

PHP threads (previously known as PHP workers) are individual PHP processes responsible for handling incoming requests to your website. Each thread processes one request at a time, meaning if you have two threads, only two requests can be processed simultaneously.

Once a PHP thread finishes processing a request (e.g., rendering a page or fetching data from a database), it becomes free to handle the next one.

PHP threads really come into play when a site doesn’t or can’t cache most of its content. The more dynamic a website is, the more PHP threads it will likely need. Cached content doesn’t require PHP threads; they’re really only needed when the site needs to query the database to get or change information. An optimized site handles requests quickly, freeing up PHP threads for the next request in the queue.

For information about how to optimize your PHP threads, refer to PHP performance.

Kinsta plans and PHP threads

The following table shows the default PHP pool, thread count, and memory per thread that are included by default in each plan at Kinsta:

PlanPool sizeThread countMemory per thread
Single 35k512MB2256MB
Single 65k1GB4256MB
Single 125k1.5GB6256MB
Single 315k1.5GB6256MB
Single 500k2GB8256MB
Single 750k2GB8256MB
WP 2512MB2256MB
WP 51GB4256MB
WP 101GB4256MB
WP 201.5GB6256MB
WP 401.5GB6256MB

You can change the number of PHP threads for each site within WordPress sites > sitename > Info > PHP performance > Change.

The following plans do not currently have access to the PHP performance feature or PHP pools. However, they include the following number of PHP threads by default:

PlanPHP threads per site
Single 1.25M10
Single 1.9M12
Single 2.5M14
Single 3.15M16
WP 608
WP 8010
WP 12012
WP 15014
Agency 206
Agency 406
Agency 608

PHP memory limit

The PHP memory limit defines the maximum amount of memory (RAM) each PHP thread can use while processing a request.

This limit is crucial because PHP scripts (especially in WordPress) often need to handle memory-intensive tasks such as large database queries, media uploads, or complex calculations.

If a script exceeds the set memory limit, it results in an error (e.g., “Allowed memory size exhausted”). This prevents one script from consuming excessive server resources.

Kinsta plans and PHP memory

Kinsta’s default memory limit is 256MB for Single 35k, 65k, 125k, 315k, 500k, and 750k, and WP 2, 5, 10, 20, and 40 plans, which is more than enough for most WordPress plugins and sites. Single 1.25M, 1.9M, 2.5M, and 3.15M, WP 60, 80, 120, and 150, and Agency 20, 40, and 60 plans have a memory limit of 512MB. This limit exists to prevent PHP scripts from consuming excessive memory. If you set the limit too high, a misconfigured or broken script can cause serious issues by using up too much memory.

You can change a site’s PHP memory limit within WordPress sites > sitename > Info > PHP performance > Change.

Interaction between PHP threads and memory

The number of PHP threads should not be confused with the PHP memory limit. PHP threads are individual PHP processes that handle incoming web requests, whereas the PHP memory limit specifies the maximum amount of memory (RAM) a single PHP script can use during execution.

PHP threads manage concurrency by processing multiple requests simultaneously, whereas the PHP memory limit manages resource allocation by restricting the memory usage of individual scripts. This prevents any single script from using all the server’s available memory.

PHP memory limits are important for scripts requiring substantial memory, such as those performing large database queries, handling large file uploads, or executing complex calculations. If you encounter memory limit errors on your site, increasing the number of PHP threads won’t resolve this issue. Instead, you should increase the memory per thread within WordPress sites > sitename > Info > PHP performance > Change.

Interaction between PHP threads, CPU, and RAM

When adding PHP threads, CPU and RAM resources must be taken into account. If you increase the number of PHP threads, but the server needs more CPU and RAM to support those threads, this will create a bottleneck because the requests won’t be handled efficiently.

Here at Kinsta, each custom LXD container is configured with 12 CPUs and 8 GB of RAM. Additionally, by using compute-optimized C2 and C3D virtual machines equipped with Google Cloud’s fastest CPUs, we help your site’s PHP threads run more efficiently. Our scalable infrastructure ensures that your WordPress site’s PHP threads have enough CPU resources to operate at peak performance.

Default PHP values

As a Managed WordPress service, Kinsta has the optimal PHP settings configured to work best with WordPress sites. If you have specific PHP requirements, feel free to reach out to our Support Team to discuss your needs.

Kinsta offers PHP 7.4, 8.0, 8.1, 8.2, 8.3 and 8.4. These are the default settings for PHP:

  • memory_limit = 256M
  • post_max_size = 128M
  • upload_max_filesize = 128M
  • max_input_vars = 10000
  • max_execution_time = 300

Disabled PHP functions

The following PHP functions are disabled on MyKinsta and cannot be enabled:

  • exec() / shell_exec()
  • popen
  • proc_open
  • proc_close
  • proc_get_status
  • proc_terminate
  • proc_nice
  • posix_kill
  • symlink
  • getmypid
  • getpwuid / posix_getpwuid
  • pcntl_signal()
  • get_current_user
  • disk_total_space()
Was this article helpful?