Google App Script Web App上的并发命中数是否有限制 [英] Is there any limit on number of concurrent hits on Google App Script Web App

本文介绍了Google App Script Web App上的并发命中数是否有限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Apps脚本(以处理电子邮件,任务和日历事件),并希望将其部署为Web App.

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

该应用程序将在运行它的用户的上下文中运行. 该应用程序将由超过1万名用户使用,甚至可能更多.

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.

在将其分发给用户之前,我想知道Web应用程序可以同时点击的次数是否受到限制?

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

在这种情况下,如果运行Web应用程序脚本的用户可以解决此限制,还是适用我的(脚本所有者)限制?如果未达到此处描述的限制,我是否可以假定它可以扩展以满足10k +用户的需求?有任何与此相关的想法或经验吗?

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?

推荐答案

如果您正在寻找此问题的解决方案,该怎么办?我使用可以工作异步处理的fetchAll方法测量了Web Apps的并发连接数.流程如下.

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. 部署Web Apps.
  2. 通过异步处理连接到Web Apps.那时,作为连接数量的工人数量发生了变化.
  3. 从Web Apps返回结果时检索错误数.

此实验的示例脚本:

客户端脚本:Google Apps脚本

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

Web Apps端脚本:

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;
  }
}

结果:

此图显示返回的错误数与工作程序数的增加.从该图可以发现,在30个以下的工作人员中没有错误,并且当工作人员超过30个时,错误也包含在返回的结果中.错误消息是Service invoked too many times in a short time: exec qps. Try Utilities.sleep(1000) between calls..这意味着,对于Web Apps,与并发访问连接的最大工人数为29.如果工人的访问时间相隔1秒以上,则不会发生错误.

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.

  • 如果将Web Apps部署为"Execute the app as:" : Me,则Web Apps脚本将以所有者身份运行.因此使用了所有者的配额.
  • 如果将Web Apps部署为"Execute the app as:" : User accessing the web app,则Web Apps脚本将以每个用户身份运行.因此使用了每个用户的配额.
  • 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.

如果这不是您想要的,对不起.

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

这篇关于Google App Script Web App上的并发命中数是否有限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆