Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6557531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:05:06+00:00 2026-05-25T13:05:06+00:00

I have a simple reporting script that takes 5-10 minutes to run. It’s triggered

  • 0

I have a simple reporting script that takes 5-10 minutes to run. It’s triggered asynchronously via an fsockopen call to run in the background. It works wonderfully some of the time. But if a user refreshes the main page while the async report triggered from the previous pageload is still running the main page hangs until the async process from the first page load completes.

Below is the rough logic behind my scripts, followed by more details of what works and what doesn’t…


main.php

if last report was already run within the hour (mysql select last report time)
    display existing report, that's it.
else
    log latest report process request
    run report asynchronously in the background (async.php)
    notification when updated report is completed (simple ajax pinger every 10s)

async.php

run report
update last report request table with "complete" status
the ajax pinger in main.php pulls the "complete" record and triggers notification

The problem

  1. User loads main.php

    Result: Great. Loads instantly, logs new report request and triggers asynchronous call as expected. Async.php will now take 5-10 minutes to complete report. All in the background.

  2. User loads main.php 20 minutes later (after the async.php finishes)

    Result: Great, loads instantly, but skips running the async report process because it’s within an hour of last request.

  3. User waits an hour and loads main.php again

    Result: All good, as in step 1

    All good so far, but…

  4. Now user loads main.php only 2 minutes after step 3.

    Result: FAIL! This page load will hang until the async process triggered in step 3 completes. Even though the mysql table with the request log time is updated instantly in step 3. Therefore step 4 should simply skip the call and just render the existing report like step 2.

What in the world? What do you recommend to debug this? If another user wants to run the same report while user 1 is hanging on step 4, this other user runs a new report just fine.

I’m not doing anything fancy in my code. Just simple if/then and mysql select lookups. The async script largely pulls in from external sources, so it’s not locking up mysql tables that might prevent a request log time lookup (a full report may only run a hundred 5ms queries over 10 minutes and none of which touch the request log).

One solution is to just cron the processes, but I’m concerned that I’m running a lot of reports that will never be seen. And instead of a report only taking 5-10 minutes it would get exponentially larger if I ran them all more frequently.

So, sticking with my above plan of attack (for now), what do you recommend? Why would step 2 load correctly, but not step 4? Is there some sort of script lock or limit per user I’m not aware of?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:05:06+00:00Added an answer on May 25, 2026 at 1:05 pm

    I ended up taking regilero’s advice. I set up a cron to run every minute and pick up any new requests in the queue. This eliminated the lag issue entirely. Thanks regilero!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have are relatively simple Reporting Services report that our users commonly export to
I have simple win service, that executes few tasks periodically. How should I pass
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have a working perl script that grabs the data I need and displays
I have written a Perl script that runs as a daily crontab job that
I have a PHP script that generates a list of places and I need
I have a simple widget that plays a sound file when pressed. Right now,
I have a somewhat simple Client/Server solution running over C# remoting (System.Runtime.Remoting). The MarshalByRef
I have simple regex \.*\ for me its says select everything between and ,
i have simple regular expression: ^123$ Matches are for example 123 1234 etc. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.