OT: limit number of connections from browser to my server?

Grant Edwards grant.b.edwards at gmail.com
Mon Jun 6 10:42:02 EDT 2016


On 2016-05-16, Grant Edwards <grant.b.edwards at gmail.com> wrote:

[...]
> Is there any way to limit the number of connections a browser uses to
> download a web page?  Browser writers seems to assume that all https
> servers are massively parallel server farms with hardware crypto
> support.

In case anybody is still wondering about this...

Various experiments have shown that if you try limit the number of
connections, browsers will fall over and not load the page completely.
You have to allow as many parallel connecitons as some addle-headed
browser devleoper wants to open -- no matter how counter-productive it
is.

I added chunked transfer encoding support to my web server so that all
connections can be kept open and re-used.  I also added a sepearte
thread to handle SSL handshaking at a lower priority so that opening a
new SSL connection doesn't block servicing requests on already open
connections.

Warm page loads are now around 1.8 seconds for all three browsers (IE,
Chrome, Firefox -- I don't have access to Safari).

On IE and Chrome, the above changes reduced cold page load times from
10-20 seconds to around 4.5 seconds.  Apparently, IE and Chrome are
sane enough to send reuqests on any idle idle connection.  So, the
entire page loads via the first connection once its SSL handshake
completes (which takes 3.5 seconds).  They still insist on opening 4-6
connections (a process which continues for 10-15 seconds after the
page has finished loading), but only the first one actually gets used
for the initial page load.

Cold load time for Firefox is still 20 seconds. Firefox seems to be
unable to pull its head out of it's arse and will sit there for 15
seconds waiting for that 6th connection to open while ignoring the
five idle connections it already has open.

The only thing I can think of to help cold page loads with Firefox is
to reduce the number of requests it has to send:

  1) Pre-process CSS and HTML files to embed images as base64 data
     instead of having the browser fetch them separately.

  2) Use preprocessing or server-side includes so that Javascript is
     embedded in the main page HTML instead of being fetched
     separately.

There are still 1-2 files that for logistical reasons I want to keep
separate, so perhaps adding Cache-Control headers to tell the browser
it can cache those files will help in cases where there are no open
connections but it's not the absolute first time the browser has seen
the device.  If I could get one particular file (jQuery-min) to be
cached, that would reduce warm page loads by 60% also.

-- 
Grant Edwards               grant.b.edwards        Yow! I have seen these EGG
                                  at               EXTENDERS in my Supermarket
                              gmail.com            ... I have read the
                                                   INSTRUCTIONS ...




More information about the Python-list mailing list