2

I have a published google csv sheet file link. I didn't share the link through email to anybody. Just published as csv and using the link as below url.

https://docs.google.com/spreadsheets/d/e/<Sheet ID>/pub?gid=0&single=true&range=B2&output=csv

My question:

How many concurrent users can request the published csv file link at the same time?

or, is there any published csv sheet limitation?

I searched google for many times but not found exact answer. If you are someone who already know about google published csv sheets limitation please answer.

Thank you so much.

TheMaster
  • 45,448
  • 6
  • 62
  • 85
planpoint
  • 29
  • 4

2 Answers2

6

The concurrent limit for a sheets published csv for a simple 1 sheet(tab) file is 500.

Test:

You can test this using UrlFetchApp.fetchAll(), since it makes concurrent requests.

function getConcurrentLimit_(numOfSimultaneousReq, id = '[[[PUBLISHED ID]]]') {
  Utilities.sleep(5 * 1000);//sleep 5s before starting
  const url = `https://docs.google.com/spreadsheets/d/e/${id}/pub?gid=0&single=true&range=A1:B1&output=csv`,
    urls = [];
  ((i) => {
    while (--i) urls.push({ url, muteHttpExceptions: true });
  })(numOfSimultaneousReq);
  const res = UrlFetchApp.fetchAll(urls);
  const statusCodes = res.map((e) => e.getResponseCode());
  const totalFailures = statusCodes.filter((e) => e !== 200).length;
  const firstFailureAt = statusCodes.findIndex((c) => c !== 200);
  return { numOfSimultaneousReq, firstFailureAt, totalFailures };
}

function test166() {
  console.log(
    [100, 500, 600, 800, 1000]
      .flatMap((e) => Array(3).fill(e))//repeat each test thrice
      .map((e) => getConcurrentLimit_(e))
  );
}

Results:

[ { numOfSimultaneousReq: 100, firstFailureAt: -1, totalFailures: 0 },
  { numOfSimultaneousReq: 100, firstFailureAt: -1, totalFailures: 0 },
  { numOfSimultaneousReq: 100, firstFailureAt: -1, totalFailures: 0 },
  { numOfSimultaneousReq: 500, firstFailureAt: -1, totalFailures: 0 },
  { numOfSimultaneousReq: 500, firstFailureAt: -1, totalFailures: 0 },
  { numOfSimultaneousReq: 500, firstFailureAt: -1, totalFailures: 0 },
  { numOfSimultaneousReq: 600, firstFailureAt: 19, totalFailures: 68 },
  { numOfSimultaneousReq: 600, firstFailureAt: -1, totalFailures: 0 },
  { numOfSimultaneousReq: 600, firstFailureAt: 71, totalFailures: 78 },
  { numOfSimultaneousReq: 800, firstFailureAt: 9, totalFailures: 256 },
  { numOfSimultaneousReq: 800, firstFailureAt: 28, totalFailures: 99 },
  { numOfSimultaneousReq: 800, firstFailureAt: 43, totalFailures: 125 },
  { numOfSimultaneousReq: 1000, firstFailureAt: 0, totalFailures: 402 },
  { numOfSimultaneousReq: 1000, firstFailureAt: 17, totalFailures: 398 },
  { numOfSimultaneousReq: 1000, firstFailureAt: 4, totalFailures: 392 } ]

As you can see, failures start at 600 concurrent requests.

TheMaster
  • 45,448
  • 6
  • 62
  • 85
  • 3
    Nicely done. Thanks – Cooper Dec 14 '21 at 20:52
  • 1
    Interesting, but 500 requests by minute? hour? second? Would someone have an official reference about this? Thanks! – Basj Jan 25 '22 at 16:17
  • 1
    Also @TheMaster, in your tests, which failures was it? `429 Too many requests` or something else? Silent timeout request with no answer? Thank you again. – Basj Jan 25 '22 at 16:19
  • 2
    @Basj I think it was ``429``. That's 500 simultaneous requests. That would be something like per less than a second or millisecond. – TheMaster Jan 25 '22 at 17:13
  • 2
    @Basj I don't think that there will be a more reputable source than experts like TheMaster because Google doesn't reveals several limits from their free services. As they haven't published they could change the limit at anytime, i.e. due to data center load, without having to report it to the public. – Rubén Jan 25 '22 at 19:14
  • 1
    Thanks @TheMaster! Maybe it would be the same limit (~500) if the requests were spaced in a 1-minute time-range, then it would be 500 per minute. I'll check this later. – Basj Jan 26 '22 at 07:50
  • 1
    PS: Do you think the limit is per IP address, or for the specific Google Sheets owner? – Basj Jan 26 '22 at 07:51
  • 3
    @Basj It's highly unlikely that requests are 500/minute. In my script, the wait time between each test is just 5s. You can see 500 requests made thrice(1500 requests) without any failures within 15s. The file is published, so I don't think the owner has to do with any limits. IP limit, maybe, but again unlikely. If anything, I think the amount of data served matters. If a request processing itself takes 5s or so, because it has to serve loads of data, then simultaneous requests will come into play due to overlap. – TheMaster Jan 26 '22 at 09:29
2

You can read about the issue here: Sheets for Developers > Sheets API > Usage limits

You probably need to be signed in.

Quotas

  • Read requests
    • Per day per project - Unlimited
    • Per minute per project - 300
    • Per minute per user per project - 60
  • Write requests
    • Per day per project - Unlimited
    • Per minute per project - 300
    • Per minute per user per project - 60

According to older posts on the subject, the numbers are changing. In this case, it's probably a good idea to search for the current 100s quotas.

How to increase Google Sheets v4 API quota limitations

Quota exceeded for quota group 'WriteGroup' Google Sheet Api Error

Edit 1

The quotas in this answer above probably won't happen because the .csv is cached.
CSV changes with delay.

The results of the experiments are uneven.

For example:

The errors did not appear until 600 simultaneous connections (in parallel). 500 was OK.

Or

  • 100 parallel connections
  • requests without closing the connection
  • a delay between requests: 0.01 s
  • The errors did not appear until the 20-second test. 15 seconds was OK.

On more and more attempts, it seems to me that the errors will start after reaching 10 MB/s.

It can point out: https://cloud.google.com/pubsub/quotas
StreamingPull streams: 10 MB/s per open stream

Edit 2:

Ten minute test, 50 threads, small file: passed

Ten minute test, 50 threads, small file: passed

Ten minute test, 50 threads, big file: passed => 10MB/s isn't the case

Ten minute test, 50 threads, big file: passed

Maybe we're facing some adaptive protection against a DDoS attack here. For example:
https://cloud.google.com/armor/docs/adaptive-protection-overview

David Lukas
  • 1,184
  • 2
  • 8
  • 21
  • 2
    Thank you for this reference. I found it before but I was not sure if this applies to Google Sheets documents shared with *"Publish to web, format CSV"* feature, or if it applies to a Google Sheets *API* that we can call like a REST API with HTTP requests. Can you find if it is the former or the latter? I didn't find this. – Basj Jan 27 '22 at 14:17
  • @Basj I've done some experiments. It seems that the quota could be one for more free projects and could be 10 MB/s. – David Lukas Jan 28 '22 at 23:04
  • 1
    `20 s are problem.` What do you mean 20 s are a problem? – TheMaster Jan 31 '22 at 15:00
  • @TheMaster The errors did not appear until the 20-second test. – David Lukas Jan 31 '22 at 15:16
  • 1
    @TheMaster I've had a theory that there was a simple limitation to 512 simultaneous connections (like older NGIX servers). But then 100 could have been OK for a while, but it's not. – David Lukas Jan 31 '22 at 15:47