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 6891299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:23:32+00:00 2026-05-27T06:23:32+00:00

I have a server with a web interface, through which a task is submitted

  • 0

I have a server with a web interface, through which a task is submitted to the server and the result is returned to the user as a web page. Sometimes the result is generated on the fly, sometimes it may take several hours. The result is written on disk and check_status function periodically checks whether the task is completed.
In the code given below it seems

while ($status == 0) {
    sleep(x);
    $status = check_status($pars);
    ...
}

hangs up the server for big tasks when the user waits until his or her task will be completed.
What would be the optimal solution to return the result to the user timely and not overload
the server with excessive requests?
Set up a limit in the loop and terminate it? Or are there modern advanced technologies to
handle these situations more efficiently?

$status = check_status($pars);
if ($status == 1) {
    ...
    print $result;
}
else {
    print $reference_to_future_result; 
}

ob_flush();
flush();

while ($status == 0) {
    sleep(30);
    $status=check_status($pars);
    if ($status == 1) {
        ...
        change_page_content_to_result;
    }
}
...
  • 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-27T06:23:33+00:00Added an answer on May 27, 2026 at 6:23 am

    If open connections to your server is an issue, I would suggest periodically polling from the client side using AJAX. The client would check in every so often, and your server would return the status of your job in a simple HTTP response.

    I would recommend building something using JavaScript’s setInterval() and jQuery‘s AJAX functionality.

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

Sidebar

Related Questions

I have a web server which is protected behind http-basic-auth. I've read through the
I have a web server which saves cache files and keeps them for 7
I have a program that is supposed to interact with a web server and
My requirement is I have server J2EE web application and client J2EE web application.
We have a Windows Server Web Edition 2003 Web Farm. What can we use
I have apache web server installed as frontend and I have j2ee SAP Netweaver
I have a web server that runs my web application. If I want to
I have a web-server, that serves different domain-names, but has only one IP-address assigned.
I have a web server with my web site and I am trying to
I have a web server located in Switzerland and it is intended to serve

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.