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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:58:43+00:00 2026-06-15T23:58:43+00:00

I have a very simple long polling ajax call like this: (function poll(){ $.ajax({

  • 0

I have a very simple long polling ajax call like this:

(function poll(){
    $.ajax({ url: "myserver", success: function(data){
        //do my stuff here

    }, dataType: "json", complete: poll, timeout: 30000 });
})();

I just picked this example up this afternoon and it seems to work great. I’m using it to build out some html on my page and it’s nearly instantaneous as best I can tell. I’m a little worried though that this is going to keep worker threads open on my server and that if I have too big of a load on the server, it’s going to stop entirely. Can someone shed some light on this theory? On the back end I have a webapi service (.net mvc 4) that calls a database, build the object, then passes the object back down. It also seems to me that in order for this to work, the server would have to be calling the database constantly…and that can’t be good right???

My next question is what is the best way on the client to determine if I need to update the html on my page? Currently I”m using JSON.stringify() to turn my object into a string and comparing the string that comes down to the old string and if there’s a delta, it re-writes the html on the page. right now there’s not a whole lot in the object coming down, but it could potentially get very large and I think doing that string comparison could be pretty resource intensive on the client…especially if it’s doing it nearly constantly.

bottom line for me is this: I”m not sure exactly sure how long polling works. I just googled it and found the above sample code and implemented it and, on the surface, it’s awesome. I just fear that it’s going to bog things down (on the server) and my way of comparing old results to new is going to bog thigns down (on the client).

any and all information you can provide is greatly appreciated.

TIA.

  • 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-15T23:58:44+00:00Added an answer on June 15, 2026 at 11:58 pm

    I agreee with SLaks – i.e. use SignalR if you need realtime web with WebApi http://www.asp.net/signalr. Long polling is difficult to implement well, let someone else handle that complexity i.e. use SignalR (natural choice for WebApi) or Comet.

    SignalR attempts 3 other forms of communication before resorting to long polling, web sockets, server sent events and forever frame (here).

    In some circumstances you may be better of with simple polling i.e. a hit every second or so to update… take a look at this article. But here is a quote:

    when you have a high message volume, long-polling does not provide any substantial
    performance improvements over traditional polling. In fact, it could be worse,
    because the long-polling might spin out of control into an
    unthrottled, continuous loop of immediate polls.

    The fear is that with any significant load on your web page your 30 second ajax query could end up being your own denial of service attack.

    Even Bayeux (CometD) will resort to simple polling if the load gets too much:

    Increased server load and resource starvation are addressed by using
    the reconnect and interval advice fields to throttle clients, which in
    the worst-case degenerate to traditional polling behaviour.

    As for the second part of you question.

    If you are using long polling then your server should ideally only be returning an update if something actually has changed thus your UI should probably “trust” the response and assume that a response means new data. The same goes for any of the Server Push type approaches.

    If you did move back down towards simple polling pullmethod then you can use the inbuilt http methods for detecting an update using the If-Modified-Since header which would allow you to return a 304 Not Modified, so the server would check the timestamp of an object and only return a 200 with an object if it had been modified since the last request.

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

Sidebar

Related Questions

I have this very simple jQuery function: $(.milestone-in-tree).live({ mouseenter: function() { setTimeout( $.ajax({ type:
I have a very simple search query that looks like this select * from
I have a very simple Resource like this for my model 'Presentacion' class PresentacionResource(ModelResource):
I have this very simple code: #include <stdio.h> #include <math.h> int main() { long
I have very simple situation and really don't have a clue why this isn't
I have a very simple JLabel with a quite long text. The parent layout
I have this very simple Combobox in my XAML: <ComboBox Name=cmb1 Width=200 Height=23 ItemsSource={Binding}
We have a very simple method that uses findById. public Cart getCart(long cartId) {
I have a very simple program but this is giving me a seg fault.
I am learning regex. I have a very simple question: I have a long

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.