Boosting performance of a FOREACH making SOAP calls

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Noodleyman
Forum Newbie
Posts: 23
Joined: Thu Jun 23, 2011 4:49 pm

Boosting performance of a FOREACH making SOAP calls

Post by Noodleyman »

Afternoon all,

I hope somebody can help, this is specific issue is driving me nuts.

I am working with php 5 in apache, not the command line and I am using a nix server. I have a foreach loop which loops 30 times. Each pass of the loop uses a different customer number.

each pass of the loop makes a SOAP API call with the new details, then processes the data returned from the API call request.

As you can probably imagine, this can take a reasonable amount of time to complete as it is calling the API 30 times. So, what I would like to do is to make it perform multiple calls at once if possible to speed the entire process up.

You are probably thinking, 30 times! can you do that in one call? Well, alas not due to the type of call I am making. The filters are not good enough in the API, so i have to re-call with different parameters to build my result set.

Now, I know that cURL will do multiple calls at once, however I am limited to the API I am working with which only accepts SOAP calls. the cURL soolution is not an option.

I believe that forking is the answer, however I have read some articles that suggest that you should not use pcntl_fork() on a web-server enviroment. I checked the manual but it doesn't verify this. I have been playing about with forking examples, but just can't seem to even get the examples to work correctly.

So, the following questions are in my mind..

Does forking work correctly in a web-server enviroment?

Does forking sound like the solution I should be aiming for?

Is there a better way to speed up the process that I should be reading up on?

Thanks in advance for any replies.
Post Reply