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

Grant Edwards grant.b.edwards at gmail.com
Mon May 16 12:06:09 EDT 2016


This is not Python specific, though I'm turning to Python to do some
experimentation and to try to prototype a solution.

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.

So, when a browser wants to load a page that has the main html file, a
css file, a javascript library or two, and a few icons and background
bitmaps, they browser opens up a half-dozen SSL connections in
parallel.

That's fine when the server is Facebook's server farm.

But when it's a small embedded device running at 40MHz with a
single-threaded web server and software crypto, it turns a 2-second
page load time into a 15-second page load time.

When we first added https support years ago, this wasn't a problem.  A
browser would open _an_ SSL connection (handshake time around 2
seconds), and then send mutliple HTTP requests over that connection to
grab a half-dozen files.  Each HTTP request would take a few tens of
milliseconds, and life was good.

Now that 2-second page load takes up to 10-15 seconds because of all
the SSL connection setup overhead involved in handling a half-dozen
"parallel" connections.

I was _hoping_ there was an HTTP header or HTML meta tag that could be
used to smack the browser with a clue bat, but there doesn't seem to
be.  [Please tell me I'm wrong...]

Some browsers used to have a global "max parallel connections" setting
that the user could control, but a) that seems to be gone from recent
versions of browsers I've looked at, and b) we can't ask customers to
change that setting just for the benefit of our devices.

So now I'm going to set up a simple Python HTTP server to try some
other approaches:

  1) Only allow the listening socket to accept 1 connection at a time.

  2) Accept the TCP connection, but don't allow the SSL handshaking to
     start on the "extra" connections.

  3) ???

  4) Profits!

Any ideas?

-- 
Grant Edwards               grant.b.edwards        Yow! What's the MATTER
                                  at               Sid? ... Is your BEVERAGE
                              gmail.com            unsatisfactory?




More information about the Python-list mailing list