Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
PHP Long Runing Process - respond back to caller, but continue with processing

Hi All,

I have implemented a REST API in PHP to return data to another application upon request. Some requests can take 30 seconds, some take 2 minutes and others can take up to an hour. If the response takes longer than 2 minutes, l need to respond back to the calling application that l will be making a callback to the calling application, once the data extract completes.

The data request can be small or very large - dependent upon what the calling application requires.

I have Google'ed around and come across the pThreads implementation, but it says that it should NOT be used in an application hosted on a WebServer. Amp looks like what l need, but l need the http response to terminate with the calling application, while the SQL continues to be generated - i.e. the http request to continue.

The other solution, that l want to avoid is to mark certain requests as long running - since some requests can take 30 seconds at certain times of the day, but exceed 2 mins at other points of the day.

The requirements are as follows:

  • Accept the request - and run the SQL to extract the data
  • If the SQL request is still running after 2 minutes, then respond back with a JSON response saying that l will use the call back mechanism. But the SQL request needs to continue, and the JSON data to be written to a flat file for the callback
  • If the SQL request completes in less than 2 minutes, respond back with the JSON response with the data

The issue is that once the SQL Request is running, the program blocks until it completes. I need the SQL request to run in a separately, and monitor how long it is taking.

Can anybody provide some sample code, and framework/ library that can help with the above?

I would gratefully accept any help with the above.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!