Linux – Does PHP script itself count as a process

curllinuxPHPprocess

My server has a limited number of concurrent processes (20) it can handle. To make sure I don't exceed I need to understand:

  1. When a user is waiting for a PHP script to finish loading, does the entire waiting duration count as one process?

  2. Most of the time waiting for the script to finish is communicating with a remote server via cURL… I believe most of the time is simply waiting for the server to respond with data. Does the whole time connected to the remote server count as a process?

I do payment processing and need to make sure nobody gets cut off. Script are run thru mod_fcgid.

Best Answer

This all depends.

If your server is running Apache with mod_php, then your PHP script will be run along with the Apache process and counted as one process (the one Apache is running for that HTTP request). However, if your script uses system calls for using external programs, then it naturally will spawn new processes and run them. Worth noting is that under mod_php each script is run with the user id Apache is running, so if the server has many users, each of them are using the same resources than the other.

If your web server is configured in some other way than Apache + mod_php (such as Apache + suPHP or Apache + fastCGI or Apache + mpm engine), counting the processes is a completely different beast. Then the scripts are run as the owner of the script and separating the resources is more simple. The principles are the same, though: each script is a single process unless it calls some external programs.

Related Topic