8

I am writing an Apps Script(to process emails, Tasks and Calendar events) and want to deploy it as a web App.

The App will run in the context of the user who runs it. The App will be used by more than 10k+ users and probably even more.

Before I distribute this to users I wanted to know if there is limit on number of concurrent hits a web App can have?

Will the limit if users running the web app script would account in this case or my(script owner) limits would apply? Can I assume that it can scale enough to meet needs of 10k+ users, provided their limits as described here are not reached? Any idea or experience related related to it?

TheMaster
  • 32,296
  • 6
  • 31
  • 56
prasun
  • 6,324
  • 9
  • 33
  • 56
  • Will the limit if users running the web app script would account in this case or my(script owner) limits would apply? Can I assume that it can scale enough to meet needs of 10k+ users, provided their limits as described [here](https://docs.google.com/macros/dashboard) are not reached? – prasun Jul 08 '13 at 05:00
  • I’m trying to figure this out as well. Many things have changed since this was asked, and now there is a specific limit on simultaneous executions per app in the documentation. But I still have some doubts. For a Web App running anonymously or as the owner of the script, it is clear the limit would be reached at 30 concurrent calls. But would that happen when the web app is run as the user accessing the app? – Diego Jul 11 '18 at 17:09

1 Answers1

13

If you are looking for the solution of this question yet, how about this? I measured the number of concurrent connections for Web Apps using the fetchAll method which can work the asynchronous processing. The flow is as follows.

  1. Deploy Web Apps.
  2. Connect to Web Apps by the asynchronous processing. At that time, the number of workers which are the number of connections is changed.
  3. Retrieve the number of error when the results are returned from Web Apps.

Sample scripts for this experiment :

Script for client side : Google Apps Script

var workers = 10; // Number of workers
var object = [];
for (var i = 0; i < workers; i++) {
  object.push({
      "url": "https://script.google.com/macros/s/#####/exec",
      "method": "get",
      "muteHttpExceptions": true,
  });
}
var startTime = Date.now();
var res = UrlFetchApp.fetchAll(object);
var endTime = Date.now();
var elapsedTime = (endTime - startTime) / 1000;
var error = res.filter(function(e){return ~e.getContentText().indexOf("Error")});
var result = [[workers, elapsedTime, (error.length > 0 ? error.length : 0)]]; // This is imported to Spreadsheet

Script for Web Apps side :

function doGet(e) {
  if (e.parameter.key == "ok") {
    var val = JSON.stringify({
      date: new Date().getTime().toString(),
    });
    Utilities.sleep(1000);
    return ContentService.createTextOutput(val).setMimeType(ContentService.MimeType.JSON);
  } else {
    return;
  }
}

Result :

enter image description here

This figure shows the number of returned errors with the increase in the number of workers. From this figure, it is found that there are no errors under 30 workers, and also when the workers are more than 30, the errors are included in the returned results. The error message is Service invoked too many times in a short time: exec qps. Try Utilities.sleep(1000) between calls.. This means that the maximum effective-number of workers who connect with the concurrent access is 29 for Web Apps. If the access time of workers is separated by more than 1 second, no error occurs.

  • If Web Apps is deployed as "Execute the app as:" : Me, the scripts of Web Apps is run as owner. So the quota of owner is used.
  • If Web Apps is deployed as "Execute the app as:" : User accessing the web app, the scripts of Web Apps is run as each user. So the quota of each user is used.

Reference :

If this was not what you want, I'm sorry.

Tanaike
  • 105,090
  • 8
  • 51
  • 83
  • Based on your experiment, it looks like 29 concurrent users can be supported. That puts any scenario where > 29 concurrent requests must be supported out of question, right? Just curious, is it possible to put some type of load balancer in front of the GAS web app? To make it support more concurrent calls? I've seen your work with GAS. It is commendable. – Malay Thakershi Nov 26 '20 at 09:44
  • @Malay Thakershi Thank you for your comment. Unfortunately, in the current stage, I have no clear answers for your 3 questions. This is due to my poor skill. I deeply apologize for this. When I could obtain the clear answers for your 3 questions, I would like to reply it. I deeply apologize for my poor skill again. – Tanaike Nov 26 '20 at 23:02
  • @Tanaiike, if 83.3k reputation is. "poor skill" then what can I say :-) In any case, I shall wait. for your response. Thank you! – Malay Thakershi Nov 27 '20 at 08:26
  • @Malay Thakershi Thank you for replying. I think that I would like to study more and get to be able to think various situations. – Tanaike Nov 27 '20 at 08:34
  • @Tanaiike, another question I have is the 30 concurrent requests is per Apps script end-point or entire account? – Malay Thakershi Nov 27 '20 at 11:51
  • @Malay Thakershi I think that it's the former. – Tanaike Nov 27 '20 at 11:54