2

I want to parallelize a php program which I use to read some .xml. I've been googleing and I read about some options:

  • fork
  • curl
  • gearman
  • exec

I also red that exec is the best, but I don´t understand how it works. Anyone who can explain it?

Thanks in advance.

Eneko
  • 149
  • 1
  • 2
  • 13

1 Answers1

2

exec doesn't parallelize. It waits for processing to finish before returning. curl can parallelize using curl_multi_init() and curl_multi_exec(). fork is pretty low level. I don't know gearman, I've only read the Basic usage example, so I cannot tell you anything about it.

Oswald
  • 31,254
  • 3
  • 43
  • 68
  • `curl` [can parallelize](http://www.php.net/manual/en/function.curl-multi-exec.php). – Jon Feb 24 '13 at 13:11
  • 1
    `exec` can run background processes (see http://php.net/manual/en/function.exec.php#Hcom86329). It can be considered as parallelizing... – tmuguet Feb 24 '13 at 13:39
  • I have been trying to install gearman on my macbook for two hours, but I could'nt. I've tried compiling it myself and installing it with homebrew, but nothing. The thing that annoyes me is that the installation progress looks correct but when I want to run my gearman server (% gearmand -d), the shell outputs 'command not found'. I think I'll try parallelizing with exec() but I don't know how to do it. If someone could give me a short explanation or a link to a good tutorial or examples, that would be great! thanks in advance. – Eneko Feb 24 '13 at 17:14
  • @tmuguet In your link, it's not `exec`, that does the parallelization. It's the command processor. This is not portable, `exec` is not even used on MS-Windows. Moreover, there is no way to capture the output of the program, let alone the execution result. Reason enough for me, to not attribute parallelization to `exec`. – Oswald Feb 24 '13 at 19:40