7

do you have any idea about the logic behind the slow connection in gmail?

Erick Petrucelli
  • 14,386
  • 8
  • 64
  • 84
Suresh S
  • 71
  • 2
  • 1
    Pinging is not related to bandwidth -- rather latency. – Ian P Mar 20 '10 at 16:06
  • @Amokrane hosts can be configured not to respond to ICMP "Echo request/reply" (i.e. `ping`) requests – Andy Mar 20 '10 at 16:11
  • 4
    Can someone with high rep _please_ change "u" -> "you" in the title. – Lucas Mar 20 '10 at 17:58
  • possible duplicate of [How to detect slow internet connections?](http://stackoverflow.com/questions/6994061/how-to-detect-slow-internet-connections) – AbdelHady Jul 28 '15 at 17:04

2 Answers2

6

I don't know if this is how Google does it (though it seems sensible), but what I'd do is perhaps time the initialisation process - e.g. "have certain key elements been initialised in the document within (say) 30 seconds" - if not, then propose to the user that their connection's slow. The language Google uses, as you know is, "this seems to be taking longer than normal", which suggests to me that they don't have an overly complicated solution to this.

Rob
  • 47,999
  • 5
  • 74
  • 91
  • @Rob 30seconds waiting for initialising. what if the server is out of service!! – Suresh S Mar 20 '10 at 16:10
  • That can be detected, as initializing can be quite a load of data, but detecting whether it is still online only takes a few bytes. – Dykam Mar 20 '10 at 16:21
  • I once looked at Gmail's sources (not everything, only the obvious parts) and this is exactly what Gmail does (and the timeout is indeed 30 seconds). – Marcel Korpel Mar 20 '10 at 17:01
4

Here is (in vastly simplified form) how I'd imagine they do it.

// Pop an alert after 30 seconds
var timeout = setTimeout(function () {
                             alert('Your connection/computer is slow!');
                         }, 30000);

// Loading logic
loadStuff();

// When done loading (if it took less than 30 seconds), 
// calling this will prevent the alert from popping up.
clearTimeout(timeout);
Casey Chu
  • 25,069
  • 10
  • 40
  • 59
  • I may try this solution for FB and related content. I won't load these social plugins for slow conn. and spare those people. ;) – Satya Prakash Jan 04 '12 at 11:22