• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

AJAX Hanging Connections?

Does the following blog article say that if I for example load all of my images from img.mydomain.com instead of mydomain.com, this will open up extra hostname connections to help these hanging connections from being a problem?

http://rdews.com/?p=30
0
jls33fsls
Asked:
jls33fsls
  • 3
  • 3
  • 2
2 Solutions
 
LeeKowalkowskiCommented:
It does.  Are you constantly requesting lots of images & AJAX simultaneously?

--
Lee
0
 
jls33fslsAuthor Commented:
Yes, I have setup a game in AJAX where lots of little images and data is pulled from the server every few seconds.  So doing what this suggests will actually help?
0
 
derelict_debrisCommented:
the article is actually talking about a specific scenario -- splitting your resources across hostnames/servers is a good idea in general, but the symptom described in the article does not directly apply to you.  

this article is talking about when you have a server app that waits until it has something to say to respond, i.e. you make a request for the latest news story, and the server page just hangs and waits until there's a new story and then sends it back to the calling app... while the server page hangs and waits it's using an allocated server HTTP connection, which, if you have hundreds of users opening connections that are simply waiting for the next news story, can cripple your server by overrunning your limit for concurrent connections.

making lots of little requests *will* eventually start clogging up a server, so distributing different bits/types of content across hostnames (and across physical servers if you're that busy) will give a performance increase, but unless you're opening 'wait'-style server scripts, you're probably a long ways off from hitting concurrent connection limits.

HTH - derelict
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
LeeKowalkowskiCommented:
Well, it'll increase Internet Explorer's bandwidth, but in turn you'll get more load everywhere else.

Is there any possibility to cache the images at least.  Try to cache or preload everything that doesn't change throughout the course of the game.

--
Lee
0
 
jls33fslsAuthor Commented:
Well I currently cache the images, but I make a lot of calls with AJAX and was thinking that things might get hung up if more than one or two went at the same time.  Is this a wrong assumption?
0
 
LeeKowalkowskiCommented:
According to http://support.microsoft.com/kb/183110 your assumption is correct.  IE does this because the HTTP1.1 specification states a client SHOULD NOT maintain more than two persistent connections per server (http://www.rfc.net/rfc2616.html#s8.1.4).

The requests will be queued though, and processed once your connection is idle.  Apparently if you use HTTP1.0 instead of 1.1, IE will use 4 connections.

Concurrent AJAX requests may be tricky to manage anyway, especially at the call-back end if you need to know which response goes with which request.  You might be better off just waiting for the response before firing off more requests, particularly if it's a request for the same data set.

I'm sure you could even come up with something to dynamically throttle the request interval in reaction to response times.

--
Lee
0
 
jls33fslsAuthor Commented:
So by adding another hostname it might help this out?
0
 
derelict_debrisCommented:
absolutely.  found this article:

http://ajaxian.com/archives/using-cnames-to-get-around-browser-connection-limits

should give you the info on what/why/how.  basically alias a few hostnames to the same location as the main site, and loop through your available hostnames with each request to allow more than the default 2-connection limit open at any one time.  Google Maps does this.

Also, you may consider consolidating your AJAX calls so you don't need so many concurrent requests -- basically call the server at set intervals with a payload describing all the info you need to retreive, and have the server send back a payload with all the results (either delimited text or xml) for your system to pull out and take the appropriate actions with.  I may be able to help with this if you have some more info on the actual request/response contents.

HTH - derelict
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now