I am familiar with php-resque and other job processing systems for processing background jobs, but I don't think it will do what I need.
In this case, I have an incoming web service request, which should perform several (2-4) independent calls to external systems and return with a consolidated response to the client. Each callout can take 300-500 ms, so I want each callout to run in parallel, so that the whole process takes no more than 500 ms +/- total.
My problem with php-resque and other systems is that wait even 1 second to start issuing these callouts, wait too long, and I am considering a different approach.
What I think:
- each individual callout is described and stored in the database with this unique request identifier
- we run jobs right away as an asynchronous php process (also known as a "workflow")
- Each worker writes his result back to the task record and indicates that it is completed
- Meanwhile, we check the task table every 50-100 ms to check the status of each task.
- when each of them is completed, we analyze the results as necessary and return the answer.
Of course, we will use a timeout for each request and the overall process ...
Thoughts? Am I mistaken? Can php-resque run multiple jobs in parallel almost instantly?
source share