jbrugger has asked for the wisdom of the Perl Monks concerning the following question:

Hi fellow monks.

I've tried to find a satisfactionary way determine a visitors bandwith, but cannot find anything, but tools to check your own, or tests where you time an up / download file.
However, what i'd like, is to write a tool (app-helper) that determines a visitors bandwith, and so redirects the user to the proper site (generated pages).
for example, i use perlmagic to create thumbnails and and a gd graph module to create graphs, but i'd like to set the width, hight and quality of previews appropriate to a users internet-speed
Then the visitor allways would be able to create better settings (and wait longer) or be content with a fast site.
i do not want to have a link in front of the pages, where the user has to select a 'speed', or quality, it has to be automatically chosen.

Replies are listed 'Best First'.
Re: Check visitors bandwidth
by Corion (Patriarch) on Mar 13, 2005 at 13:31 UTC

    Please don't. I hate websites where I can't simply chose the "low-calorie" version. If in doubt, maybe always select the Java/Flash version after a short timeout, and have a prompt "click here to see the HTML version". My company for example has a fast connection, but my machine there is a lowly P-II 300 with 256 MB of RAM, so I don't want a JVM hogging all the RAM that FireFox and Lotus Notes leave.

      I need to... It's not for 'public' users that browse the internet, but for a web application that alreaddy sets some requirements to the users machine. (eg. for client side processing of some data).
      The visitors / users do have the proper machines, but not allways the proper internet connection
      For example, you could think of sales persons who have to show a live demo version of a system, using good laptops, but bad internet connections.
        Perhaps your company is better off not hiring sales staff that cannot decide between two big buttons, one labelled

        PRESS THIS IF YOUR INTERNET CONNECTION IS GOOD

        and the other

        PRESS THIS IF YOUR INTERNET CONNECTION IS BAD

        Or write a small application that can be run from the sales persons' laptop that determines the connection. But anything that bases a decision on a single probe will have to live with the risk of making the wrong decision. Your current connection speed isn't the only you will have 10 seconds from now.

        What is a 'proper' machine? intel? ppc? what about arm7tdmi?

        It used to be that anything that can run perl should be regarded as 'proper'.

Re: Check visitors bandwidth
by gam3 (Curate) on Mar 13, 2005 at 17:33 UTC
    If you are using cgi, just time how long it takes to send some # of bytes to the user. I would think that this is going to take some tuning, as it is very hard to tell a bad connection from a slow connection.

    You need to think about how short term congestion on the network will affect what you think a users bandwith is.

    You might want to look at rrdtools http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/. It would let you keep a history of bandwidth and get averages over some period of time.

    A picture is worth a thousand words, but takes 200K.
Re: Check visitors bandwidth
by Fletch (Bishop) on Mar 13, 2005 at 13:35 UTC

    Seconded. Just give the user an option (defaulting to the smaller version) and use that preference to decide which version to send. And/or make a link to the "other" version from each ("Hey, Joe may be interested in this; let me send him the small one to his cell phone.")