Multiple threads?



Hiya. I'm sure this question has come up on this group many times before,
but I can't find any prior discussion. (Appologies if I missed it.)

I have a PHP program looking a bit like this.

Read a load of data over the network from node 1.
Process the data.
Read a load of data over the network from node 2.
Process the data.
....
Read a load of data over the network from node n. (2<n<50)
Process the data.
Combine all the data together and report.

The time spent waiting for the remote node could be better spent processing
the data. I'd also like to make many requests at the same time, rather than
waiting for one to report before making the next request.

In short...

For each node, start a ReadAndProcess thread.
Wait for each thread to report back in the order they complete.
Once all threads have reported, sort, combine and report.

How do PHP developers do this please?

(If I were using C#, I'd create and start a Thread for each node. The main
thread would then enter a Monitor.Wait state as each worker thread
performed a Monitor.Pulse on completion, leaving data in a shared object.)

Bill, context switch!

--
http://billpg.me.uk/ usenet(at)billpg(dot)me(dot)uk
.



Relevant Pages

  • Re: Total Requests/sec problem
    ... We also have users that are on 3mb connections that are having long load ... I want to say that it is the overhead of some many requests and the reponse ... are presented with the Pop-up windows authentication prompt. ... Network monitor trace from one client and the server. ...
    (microsoft.public.sharepoint.portalserver)
  • Re: Multiple threads?
    ... Bill Godfrey wrote: ... > Read a load of data over the network from node 1. ... > Combine all the data together and report. ...
    (comp.lang.php)
  • Reports/Forms Wizard Error
    ... computer was on a network and the systems people had to ... >to generate a report from the Report Wizard. ... >the wizard is unable to load the reports and/or forms. ...
    (microsoft.public.access.reports)
  • loading a report
    ... i use the following code to load a CR10 report, then set the logon info for ... problem we are having is that on the load it seems to hang for about 30s as ... if we run it with the old database connected into the network it will not ...
    (microsoft.public.vb.crystal)
  • Re: 100,000 calls a minute to a web service
    ... multi-threaded) then would the network handle this load and also could ... the web service handle this many requests at once (i know the W3C ... Have you talked to the developer of the original web service? ...
    (microsoft.public.dotnet.framework.webservices)