How does GWT manage browser concurrent request limits?

94 views
Skip to first unread message

Transplant

unread,
Nov 6, 2007, 11:15:28 PM11/6/07
to Google Web Toolkit
Does GWT provide any support for managing the maximum open request
limits of the browser? How does a GWT app answer the questions of:

1) What is the maximum # of concurrent requests allowed by the
browser?

2) Did the browser stomp my request because it exceeded the limit?

If I code the application to allow only one async request at a time is
it guaranteed to work? Or do other pages in the browser have the
ability to out-compete my app for a single connection resource?

What are the best practices surrounding this issue?

abickford

unread,
Nov 7, 2007, 8:53:30 AM11/7/07
to Google Web Toolkit
GWT is javascript on the client. If javascript can't do it, neither
can GWT.

Most browsers only allow 2 connections, but in general it doesn't
matter. If you make another request while there are 2 outstanding
ones, that request gets put in a queue and will eventually be made.
Unless you are trying to do some kind of Comet style app, you really
shouldn't be concerned w/the exact request implementation/connection
limits, etc.

Jason Essington

unread,
Nov 7, 2007, 10:44:04 AM11/7/07
to Google-We...@googlegroups.com

On Nov 6, 2007, at 9:15 PM, Transplant wrote:

>
> Does GWT provide any support for managing the maximum open request
> limits of the browser?

Pretty much this is left up to the browser to handle.

> How does a GWT app answer the questions of:
>
> 1) What is the maximum # of concurrent requests allowed by the
> browser?

You get 2 concurrent requests to any given host.

> 2) Did the browser stomp my request because it exceeded the limit?

Nope, they are queued by the browser, and once one of the active
requests finishes the next one in the queue is sent.

> If I code the application to allow only one async request at a time is
> it guaranteed to work?

Sure, if you handle queuing yourself it works fine, though it is
unnecessary.

> Or do other pages in the browser have the
> ability to out-compete my app for a single connection resource?

Other pages have their own connection limits (assuming they are going
to different hosts), even if they aren't, you will still not "lose"
any requests (see #2)

> What are the best practices surrounding this issue?

Just don't worry about it and let the browser handle it. the only
time it could be a problem is if you have many long lived connections
going to the same host.

-jason

Reinier Zwitserloot

unread,
Nov 7, 2007, 3:51:01 PM11/7/07
to Google Web Toolkit
Everything that Jason said, plus:

When you use GWT's ImageBundle system, the images count as 1
connection instead of hundreds.

If that's STILL not good enough, you can load certain resources from
different virtual servers. For example, you can load your image from
img.yourserver.com (which just points to the exact same IP address and
is in fact no different in any way from just using www.yourserver.com,
but the browser doesn't know that and gives img.yourserver.com its own
2 connection limit pool). You can only do this for static resources
because for JS stuff, you need to keep the same origin policy in mind
(and img.yourserver.com is another origin - that's the point).

If you need to run multiple server-push connections, you need cometd.
For an intro on what server-push is, see:

http://code.google.com/p/google-web-toolkit-incubator/wiki/ServerPushFAQ

It's likely you're not using Server Push. If you aren't, you basically
don't need to worry about the 2 connection limit.

Reply all
Reply to author
Forward
0 new messages