0

We have a query that takes about 10 minutes to complete but it seems that PHP doesn't want to wait around for it. If the user does, PHP will respond with the actual query in plain text. No errors or anything like that are reported.

We thought it was an Apache thing, tried to configure it, didn't work, swapped over to nginx and it still gets the same result.

I call set_time_limit(0); at the very beginning of the script.

What is it I'm missing?

EDIT: I'd like to clarify that PHP isn't doing any computation. It's simply waiting for the result of a query from the database and then formatting the result into an Excel file.

zelarian
  • 121
  • 1
  • 4

2 Answers2

0
  1. Try setting "max_execution_time" with ini_set("max_execution_time", 0); but PHP was not build for this kind of work - try to use different dev language (Python, NodeJS?)

  2. Did you try to make your query more optimized? Or try running it in more steps. Try generating some tables with partial results. Then re-do the query on those?

Jan M.
  • 127
  • 2
  • 14
-1

Unfortunately php is not built for heavy processing

I also had this problem in some of my code

My suggestion is:

  • Use of micro-service structure (nodeJs, Java ,etc.)
  • Use queuing and split processing into smaller sections

But in general, it is better to entrust heavy processing to another programming language

Like Java,python, ect

You can read more about this on these sites: https://www.reddit.com/r/PHP/comments/2pyuy0/heavy_data_processing_in_php/

Best way to manage long-running php script?

mahdi-mh
  • 1
  • 1
  • It's not really heavy processing. All it does is send a query to a db, wait for the response, and then write that to an Excel file. – zelarian Mar 01 '21 at 21:44
  • you said "We have a query that takes about 10 minutes to complete" but it is not really heavy processing ? – mahdi-mh Mar 03 '21 at 07:24
  • The processing happens in SQL on our db server, no in PHP. PHP is simply waiting for a response from the query. – zelarian Mar 03 '21 at 16:46