Gmail – How Google Dynamically Counts Space for Gmail

gmailgoogle

When we look at Gmail login page, we can see the space counting dynamically. What does it represent – does it mean that Google is dynamically increasing it's server space?

What happens in the back end while the Gmail space gets dynamically increased?

enter image description here

Best Answer

As Al mentioned, it's just a gimmick plus some JavaScript trickery that shows the 'real-time' increase - in practice, the amount is a fixed space which gets increased at regular intervals.

This Stack Overflow answer explains how the JS bit works

This is the code in charge of it. Looks like it is based on a time computation being mapped to a number of Bytes.

function updateQuota() {
  if (!quota_elem) {
  return;
  }
  var now = (new Date()).getTime();
  var i;
  for (i = 0; i < CP.length; i++) {
    if (now < CP[i][0]) {
      break;
    }
  }
  if (i == 0) {
    setTimeout(updateQuota, 1000); 
  } else if (i == CP.length) {
    quota_elem.innerHTML = CP[i - 1][3];
  } else {
    var ts = CP[i - 1][0];
    var bs = CP[i - 1][4];
    quota_elem.innerHTML = format(((now-ts) / (CP[i][0]-ts) * (CP[i][5]-bs)) + bs); 
    setTimeout(updateQuota, 1000); 
  } 
} 

var PAD = '.000000';