yretuta
yretuta

Reputation: 8091

What are "multiple processes" in PHP?

"I would prefer it to be written in PHP or Java (I know PHP can't do multiple threads, but it could be accomplished with multiple processes)".

What does this statement mean when it says "multiple processes"? Are there any good examples out there?

Upvotes: 0

Views: 214

Answers (3)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798944

The best example of "multiple processes" is Apache httpd itself. Starting it brings up a "parent" process which then starts one or more "child" processes that handle the requests:

# ps auxfww | grep '[h]ttpd'
root      8632  0.0  0.2 247376  8380 ?        Ss   05:57   0:00 /usr/sbin/httpd
apache    8635  0.0  0.1 247376  4716 ?        S    05:57   0:00  \_ /usr/sbin/httpd
apache    8636  0.0  0.1 247376  4716 ?        S    05:57   0:00  \_ /usr/sbin/httpd
apache    8637  0.0  0.1 247376  4716 ?        S    05:57   0:00  \_ /usr/sbin/httpd
apache    8638  0.0  0.1 247376  4716 ?        S    05:57   0:00  \_ /usr/sbin/httpd
apache    8639  0.0  0.1 247376  4716 ?        S    05:57   0:00  \_ /usr/sbin/httpd
apache    8640  0.0  0.1 247376  4716 ?        S    05:57   0:00  \_ /usr/sbin/httpd
apache    8641  0.0  0.1 247376  4716 ?        S    05:57   0:00  \_ /usr/sbin/httpd
apache    8642  0.0  0.1 247376  4716 ?        S    05:57   0:00  \_ /usr/sbin/httpd

Upvotes: 0

Guillaume
Guillaume

Reputation: 5553

A process it more or less a program launch. For instance if you launch a web server two times you will have two process, which will be able to respond to different requests at the same time.

A thread is more or less a sub-process inside a process. That way web server usually have multiple thread handling requests from different users. That mean that multiple requests can be handled at the same time by only one process.

Upvotes: 1

Pascal MARTIN
Pascal MARTIN

Reputation: 401122

Multiple-processes means several processes, probably executed in parallel.

And a "process" is just an execution of a program.

So, multiple-processes means several executions of a program -- in parallel, to achieve some kind of multiple-threads result : instead of having one program with several threads, which is not possible in PHP, you launch the same program more than once in parallel (and, generally, each instance of a program will work with a subset of the total amout of data).

Upvotes: 0

Related Questions