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.

3
  • Read the manual for each one and determine which one best suits your needs... Commented Feb 24, 2013 at 12:31
  • exec doesn't parallelize anything because it waits for the spawned process to exit before returning. Commented Feb 24, 2013 at 13:10
  • See stackoverflow.com/questions/2101640/… Commented Feb 24, 2013 at 13:31

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

exec can run background processes (see php.net/manual/en/function.exec.php#Hcom86329). It can be considered as parallelizing...
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.
@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.