473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

parallel XmlHttpRequests

I'm trying to run multiple xmlhttprequests in parallel in response to a
button click.
I want to launch N asynchronous requests and handle the responses as
they come. The problem is that no request is actually transmitted until
the previous one finishes, as though the browser limits the number of
actual connections to 1 and puts my requests in a queue. I tried this
on FF and IE.
Here's the code:

function newReq() {
if (window.XMLHttpRequest)
return new XMLHttpRequest();
else
return new ActiveXObject("Microsoft.XMLHTTP");
}

function Query(url) {
var req = newReq();
var url = url;
this.onres = function () {
if (req.readyState != 4) return ;
document.getElementById('results').innerHTML =
document.getElementById('results').innerHTML + "one more
response<br>";
}

this.go = function go() {
req.open("GET", url, true);
req.onreadystatechange = this.onres;
req.send(null);
}
}

d = new Query("foo1");
d.go();
e = new Query("foo2");
e.go();
f = new Query("foo3");
f.go();
g = new Query("foo4");
g.go();

Dec 28 '06 #1
17 4260
Assaf Lavie wrote:
I'm trying to run multiple xmlhttprequests in parallel in response to a
button click.
I want to launch N asynchronous requests and handle the responses as
they come. The problem is that no request is actually transmitted until
the previous one finishes, as though the browser limits the number of
actual connections to 1 and puts my requests in a queue. I tried this
on FF and IE.
This is a limit to the HTTP 1.1 protocol which is in place to prevent
the browser from flooding a server and to protect the net a little
against hackers and other bad guys. The reasons for the limit didn't
stand the test of time, they're not important today so much but the
browsers still respect the limits because they're part of the protocol
specifications.

You can get around this by modifying the client to handle more than 2
requests ( http://www.ajaxperformance.com/?p=33 ), but this is practical
only for intra-nets, another option is to use the Opera browser which
seem to ignore the limits. Again, only practical for intranets.
You can find a very good technical overview of the problem here:
http://www.oreillynet.com/xml/blog/2...about_xhr.html

Sorry, but there's no good answer for the question you have.

--
http://www.hunlock.com -- Musings in Javascript, CSS.
$FA
Dec 28 '06 #2
"Assaf Lavie" <as********@gmail.comwrote in news:1167325992.976614.16400@
73g2000cwn.googlegroups.com:
I'm trying to run multiple xmlhttprequests in parallel in response to a
button click.
I want to launch N asynchronous requests and handle the responses as
they come.
http://www.hunlock.com/blogs/Concurrent_Ajax

Dec 28 '06 #3
pcx99 wrote:
You can get around this by modifying the client to handle more than 2
requests ( http://www.ajaxperformance.com/?p=33 ), but this is
practical only for intra-nets
Why is it practical only for intranets? You mean, you can't control every
user's settings? This is true.

But everyone should increase the limits in their browsers. It speeds up the
web :)

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Dec 28 '06 #4
pcx99 wrote:

[snip]
This is a limit to the HTTP 1.1 protocol which is in place to prevent
the browser from flooding a server and to protect the net a little
against hackers and other bad guys.
The connection limits are present to prevent general congestion -- a
hacker out to cause problems isn't about to respect protocol
limitations. The Internet does have finite capacity and congestion is
still a real concern. Servers also have a limit to the number of
connections that can be effectively managed.

Getting Web developers to understand the HTTP specification should help.
Simple things like sending a Content-Length header with
dynamically-generated responses would be a start. This eliminates the
need to discard connections: every entity across a persistent connection
must have self-defined length (4.4, RFC 2616) otherwise the end of the
message needs to be indicated by closing the connection.
The reasons for the limit didn't stand the test of time, they're not
important today so much ...
On what basis do you draw that conclusion? Doubling the number of
connections, for instance, doesn't guarantee an increase in performance,
and can you state for certain what effect it would have on the Internet
as a whole if implemented on a large scale?

I can't answer that question, which is why I would steer clear of
recommending practice like that when it may be harmful.
but the browsers still respect the limits because they're part of the
protocol specifications.
Doubtful. There isn't a single "mainstream" browser that is even
conditionally compliant with RFC 2616, though the extent of the
violations differ from one to the next.

The connection limit is only a recommendation, not a requirement for
compliance -- though recommendations in Standards Track RFCs are made
with a lot of weight. I would prefer to think that this recommendation
is heeded because there is little real reason to do otherwise.

[snip]

Mike
Dec 29 '06 #5
On 28 Dec 2006, ne********@mattkruse.com wrote:
But everyone should increase the limits in their browsers. It speeds
up the web :)
To be precise, it speeds up the individual experience. It makes web
servers slower because they serve more parallel requests, so it hurts
other users.

Ted
Dec 29 '06 #6
Well, first of all, it seems the browser's limit on my machine is 1
connection, not 2. I know this from sniffing, not from the settings. I
can see the 2nd request only goes out once the first one is done.
According to FF's settings the limit is higher than 2. I raised all the
"max" settings to like 10 but it doesn't seem to have any effect. Keep
alive is also enabled. Could it be IIS that's limiting me? (running
locally) Any other ideas?

Thanks,
Assaf

pcx99 wrote:
Assaf Lavie wrote:
I'm trying to run multiple xmlhttprequests in parallel in response to a
button click.
I want to launch N asynchronous requests and handle the responses as
they come. The problem is that no request is actually transmitted until
the previous one finishes, as though the browser limits the number of
actual connections to 1 and puts my requests in a queue. I tried this
on FF and IE.

This is a limit to the HTTP 1.1 protocol which is in place to prevent
the browser from flooding a server and to protect the net a little
against hackers and other bad guys. The reasons for the limit didn't
stand the test of time, they're not important today so much but the
browsers still respect the limits because they're part of the protocol
specifications.

You can get around this by modifying the client to handle more than 2
requests ( http://www.ajaxperformance.com/?p=33 ), but this is practical
only for intra-nets, another option is to use the Opera browser which
seem to ignore the limits. Again, only practical for intranets.
You can find a very good technical overview of the problem here:
http://www.oreillynet.com/xml/blog/2...about_xhr.html

Sorry, but there's no good answer for the question you have.

--
http://www.hunlock.com -- Musings in Javascript, CSS.
$FA
Dec 31 '06 #7
Ted Zlatanov wrote:
On 28 Dec 2006, ne********@mattkruse.com wrote:
>But everyone should increase the limits in their browsers. It speeds
up the web :)
To be precise, it speeds up the individual experience. It makes web
servers slower because they serve more parallel requests, so it hurts
other users.
That would be a very tough case to prove, or even provide evidence for!

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jan 2 '07 #8
If You can set the maximum number of connections with IIS. Be advised
that if you are running it on a workstation for development purposes,
IIS sets a very low limit on the number of concurrent connections. You
get a license warning if you try to exceed it. I use IIS5 on W2kWS to
test with 3 browsers at once, and I am constantly getting timeouts
waiting for connections. It can be a good test of how your web
application performs in the face of adversity. I don't have this
limitation with Apache on Windows.

You can test with Firefox and the FasterFox extension (which is very
popular). FasterFox allows you to up the number of concurrent
connections. [This is bad news for web servers] FasterFox also gives a
fine degree of control. Some sites will block you if you use FasterFox.
DnsStuff.com comes to mind...

My website can handle as many concurrent XmlHttpRequests as the
connection will allow. I tag outgoing requests and incoming responses
with an Id that allows me to match them up and do high-level caching on
the client. It works well and gives good performance. I no longer
support browsers that don't support Ajax.

Gerard Vignes
http://www.GerardVignes.com
Seattle, WA

Jan 2 '07 #9
www.gerardvignes.com wrote:
I no longer
support browsers that don't support Ajax.
That's too bad. Since IE6 uses ActiveX for Ajax, and I have all ActiveX
disabled for public sites, I don't get any Ajax functionality when I am
using IE6. On some sites, this means a blank page. Of course, I just leave
those sites :)

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jan 2 '07 #10
i am sorry, but i won't help you, i just want to say "what a great
code!" really, it is very nice, using method with ajax, is really very
good idea.

thx for space ;]

Assaf Lavie napísal(a):
[...]

Jan 2 '07 #11
Hi Matt,

Matt Kruse wrote:
www.gerardvignes.com wrote:
>I no longer
support browsers that don't support Ajax.

That's too bad. Since IE6 uses ActiveX for Ajax, and I have all ActiveX
disabled for public sites, I don't get any Ajax functionality when I am
using IE6. On some sites, this means a blank page. Of course, I just leave
those sites :)
Any reason you have for still using IE6?

Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Jan 2 '07 #12
Laurent Bugnion [MVP] wrote:
Any reason you have for still using IE6?
Corporate standard.

When I can control my browser choice, I use FF ;)

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jan 2 '07 #13
On Tue, 02 Jan 2007 20:00:40 +0100, "Laurent Bugnion [MVP]"
<ga*********@bluewin.chwrote:
>Hi Matt,

Matt Kruse wrote:
>www.gerardvignes.com wrote:
>>I no longer
support browsers that don't support Ajax.

That's too bad. Since IE6 uses ActiveX for Ajax,
no it doesn't only certain flavours of it, and the least interesting
really as they're not as flexible as other forms.
>and I have all ActiveX
disabled for public sites, I don't get any Ajax functionality when I am
using IE6. On some sites, this means a blank page. Of course, I just leave
those sites :)

Any reason you have for still using IE6?
IE7 is a piece of crap? with a UI designed for a 5 year old?

Jim.
Jan 2 '07 #14
Hi Jim,

Jim Ley wrote:
On Tue, 02 Jan 2007 20:00:40 +0100, "Laurent Bugnion [MVP]"
<ga*********@bluewin.chwrote:
>Any reason you have for still using IE6?

IE7 is a piece of crap? with a UI designed for a 5 year old?

Jim.
Compared to IE6, IE7 is much better. Maybe not the UI (though I really
don't like the IE6 UI), but the engines.

I still prefer Firefox, but IMHO there are no reasons to continue using
IE6 over IE7...

Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Jan 2 '07 #15
On Tue, 02 Jan 2007 20:25:55 +0100, "Laurent Bugnion [MVP]"
<ga*********@bluewin.chwrote:
>I still prefer Firefox, but IMHO there are no reasons to continue using
IE6 over IE7...
Except for the UI... the FireFox Ui is also rubbish, although that
would help if it understood how to take native controls, and follow
the UI settings in the window manager a little more.

Jim.
Jan 2 '07 #16

Jim Ley wrote:
On Tue, 02 Jan 2007 20:00:40 +0100, "Laurent Bugnion [MVP]"
<ga*********@bluewin.chwrote:
Matt Kruse wrote:
That's too bad. Since IE6 uses ActiveX for Ajax,

no it doesn't only certain flavours of it, and the least interesting
really as they're not as flexible as other forms.
Yes it does, unless you're talking about iframe refreshing which I is
not only a huge pain but also does not really fit most peoples
conception of AJAX. But, actually, I'm more perplexed by Matt's
disabling ActiveX. Why? Why would you continue to use IE6 and disable
the one feature that makes it worth using?

Bob

Jan 3 '07 #17
beegee wrote:
<snip>
... . But, actually, I'm more perplexed by Matt's disabling
ActiveX. Why? Why would you continue to use IE6 and disable
the one feature that makes it worth using?
You disable ActiveX for the Internet security zone because there is a
big difference between an ActiveX component being "marked safe for
scripting" and its actually being safe.

Richard.

Jan 3 '07 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Martin | last post by:
I have a situation where I'm using XmlHttpRequests to update some data in a table every few seconds. The script that executes when the data comes into the browser checks to see if the data has...
3
by: paytam | last post by:
Hi all, Is it possible to write parallel programming in C? I mean for example a simple program like I have a clock on a program that show me current time and and at the same time another job like...
126
by: ramyach | last post by:
Hi friends, I need to write a parallel code in 'C' on the server that is running SGI Irix 6.5. This server supports MIPS Pro C compiler. I don't have any idea of parallel C languages. I looked...
11
by: lovecreatesbeauty | last post by:
For example, line L1 and line L2 are two lines in two-dimensional space, the start-points and end-points can be described with following the `point_t' type. The start-points and end-points are:...
4
by: jeff.maildump | last post by:
Hi, I've got multiple xmlhttprequests which are in a loop. So this is the loop I have so far, with the closure given to me in a previous post: ...
4
by: Soren | last post by:
Hi, I want to control some motors using the parallel port.. however, my laptop does not have any parallel ports (very few do). What I do have is a USB->Parallel converter... I thought about...
26
by: Prime Mover | last post by:
Hello all, I have got the pseudo-code below that I would like to convert to c language. The algorithm calculates Pi value. I am somewhat familiar with C language, but I am just starting to learn...
3
by: John | last post by:
I have a program that needs to run on a regular basis that looks at a queue table in my database. If there are items in the queue database I need to grab the data from the database and pass it to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.