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

  • Home
  • SEARCH
  • 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 6326315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:04:00+00:00 2026-05-24T17:04:00+00:00

After a PHP web page from an Apache server is loaded by the browser,

  • 0

After a PHP web page from an Apache server is loaded by the browser, client side javascript is sending AJAX requests every 5 seconds to a PHP update script. The AJAX response, encoded in JSON, can be quite large, so I want to send simply the empty array ‘[]’ if there is no change since the previous AJAX request, or the entire array containing various JSON objects if there has been a change since the last AJAX requests.

To implement sending ‘[]’ or the full array I’m using a session variable. My update script looks like:

<?php
session_start();
$output = '[]'; // server is running PHP 5.1 so can't use built in JSON encode
// code here queries a database and updates $output based on the query result
if (isset($_SESSION['previous_output'])) {
    if ($_SESSION['previous_output'] == $output) {
        echo '[]';
    } else {
        $_SESSION['previous_output'] = $output;
        echo $output;
    }
}
?>

After implementing the above script, the web server administrator noticed “too many” httpd processes being created and hanging around, eventually bringing the server to a grinding halt.

When I remove the code involving the session variables, some httpd processes still hang around, but the “backlog” is not as bad, and eventually the processes go away before there is noticeable impact on the server.

The web server is not heavily used, serving maybe half a dozen “visitors’ at any time. The web page doing the 5 second AJAX requests is “protected”, meaning only a single admin user can access it at a time.

I found another posting at PHP MySQLi Singleton for Ajax-Requests end in to many processes that sounds similar, and it refers to the AJAX Push Engine (APE) project, which I would like to investigate further eventually. However, I am currently pressed for time and resources (e.g. cannot setup an APE server…), so I am at a lost as to what can be done.

Any advice on how to do the 5 second AJAX requests without adversely impacting server performance? Why would the use of the session variable make such a noticeable difference?

  • 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-24T17:04:01+00:00Added an answer on May 24, 2026 at 5:04 pm

    Apache tries to maintain a set of idle workers to process incoming requests. These settings can be tweaked (min number of idle workers, max number of workers – of particular interest MaxRequestsPerChild, try lowering this value). This shouldn’t cause a problem – assuming your script is terminating correctly (this shouldn’t be an issue for the typical web app). You might get a thorough answer from the serverfault community.

    Also, depending on the server load (# of active users, resources the api uses, etc.), you might need to scale you app (research autoscaling with amazon’s ec2 service).

    http://httpd.apache.org/docs/2.0/mod/worker.html

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

Sidebar

Related Questions

After I upload my PHP files to my web host, I view the page
I am trying to receive a json object back from php after sending data
I am trying sending data from android application (with emulator) to web server (a
On a PHP-based web site, I want to send users a download package after
I have a partly inherited web application in PHP and after poking around with
What is the Java equivalent of PHP's $_POST ? After searching the web for
After compiling PHP from source are the devel libraries still needed? For example, I
Great page this one, coming from the perl world and after several years of
Web page contains php includes: <?php include 'http://www.example.com/header.txt'; ?> and <?php include 'http://www.example.com/footer.txt'; ?>
In HTML, I can find a file starting from the web server's root folder

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.