skip to Main Content

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.

2

Answers


  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?

    Login or Signup to reply.
    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?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search