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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:56:55+00:00 2026-06-01T02:56:55+00:00

I implemented heartbeat as the following $.ajax({ cache:false, timeout:8000, type:POST, url:someurl.php, data:allFormValues, error:function(){ alert(some

  • 0

I implemented heartbeat as the following

$.ajax({
    cache:false,
    timeout:8000,  
    type:"POST",
    url:"someurl.php",
    data:allFormValues,
    error:function(){ alert("some error occurred") },
    success:function(response){ //call some functions  }
   });

and in the server side

$time = time();
        while(!proccessServer() && (time() - $time) < 60 )
        {
            sleep(5);
        }

and simply it call a function if it returns false the loop will sleep for more 5 seconds and then check
but the problem is this thing is eating my resources CPU
and this was only when 5 users testing it

I used before this

window.setInterval(function(){
  //I call a function here 
}, 5000);

but also it was eating the resources because of many requests

and maybe my app have 100K online at the same time
also I am not thinking about using websockets because of browsers compatibility
What do you suggest to solve this ?
any help is appreciated

  • 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-06-01T02:56:56+00:00Added an answer on June 1, 2026 at 2:56 am

    Your web server (Apache?) will use one thread until the request completes, which eats resources. AND you are using a PHP process for each visitor, just waiting. PHP is not very suitable for such solutions. You should look at other technologies if you want to do Comet. For example node.js.

    You could also switch to NGiNX as web server, and use NGiNX_HTTP_Push_Module from http://pushmodule.slact.net/ for you application, and then stay with PHP. NGiNX will then accept the connection from your visitor and then wait for your code to push data to NGiNX. It might work for you, depending on what exactly you want to do.

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

Sidebar

Related Questions

I implemented the following code: NSURL *url = [ NSURL URLWithString:[ NSString stringWithFormat: @http://www.google.com/search?q=%@,
I implemented a rollback mechanism for my php execution so if an error occurs
I implemented my Cub3r like this <script type=text/javascript> var flashvars = {}; flashvars.xml =
I've implemented a kind of 'heartbeat solution' and I'd like to see what happen
I implemented push notifications using APNS-PHP http://code.google.com/p/apns-php/ on my server. I now have to
I implemented the following TextView in a RelativeView: <TextView android:id=@+id/textView1 android:layout_width=wrap_content android:layout_height=wrap_content android:layout_alignParentRight=true android:layout_alignParentTop=true
I implemented a Ajax callback function to update a div (announcement) in my web
I always thought that if you didn't implement a heartbeat, there was no way
Implemented a generic repository with several Methods. One of those is this: public IEnumerable<T>
I implemented Forms authentication by creating Default.aspx and custom login page named login.aspx .

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.