title: Using a distributed processing system for FOREGROUND requests in PHP
body: <p>I'm familiar with php-resque and other job-processing systems for handling background jobs, but I don't think it'll do what I need.</p>
  
  <p>In this case, I have an incoming web service request that needs to perform multiple (2-4) independent callouts to external systems and return with a consolidated response to the client. Each callout might take 300-500ms, so I want each callout to be performed in parallel so that the entire process takes no more than 500ms+/- total.</p>
  
  <p>my problem with php-resque and other systems is that waiting even 1 second to start issuing those callouts is too long to wait, and I'm considering another approach.</p>
  
  <p>What I'm thinking:</p>
  
  <ol>
  <li>each individual callout is described and stored in a database with a given unique request ID</li>
  <li>we kick off the jobs immediately as a asynchronous php process (aka "worker process")</li>
  <li>Each worker writes its result back to the job record and indicates that it's complete</li>
  <li>meanwhile, we poll the job table every 50-100ms to check on the status of each job</li>
  <li>when each is complete, we parse the results as necessary and return the response.</li>
  </ol>
  
  <p>Of course, we'd implement a timeout for each request and the overall process...</p>
  
  <p>Thoughts? Am I wrong? Could php-resque kick off multiple jobs in parallel virtually instantly?</p>