问题描述
我正在编写应用程序脚本(用于处理电子邮件、任务和日历事件)并希望将其部署为网络应用程序.
I am writing an Apps Script(to process emails, Tasks and Calendar events) and want to deploy it as a web App.
应用程序将在运行它的用户的上下文中运行.该应用程序将被超过 10k+ 用户使用,甚至可能更多.
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?
在这种情况下,运行网络应用程序脚本的用户是否会受到限制,或者我的(脚本所有者)限制是否适用?如果未达到此处所述的限制,我是否可以假设它可以扩展到足以满足 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 应用程序的并发连接数.流程如下.
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.
- 部署网络应用.
- 通过异步处理连接到 Web 应用程序.那时,worker 的数量即连接数发生了变化.
- 检索从 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?key=ok",
"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 应用程序端脚本:
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;
}
}
结果:
该图显示了随着worker数量的增加返回错误的数量.从这个图中可以发现,30个worker以下没有错误,而且当worker超过30个时,错误也包含在返回的结果中.错误信息是 Service 在短时间内调用了太多次:exec qps.在调用之间尝试 Utilities.sleep(1000).
.这意味着对于 Web Apps,与并发访问连接的最大有效工作人员数量为 29.如果worker的访问时间间隔超过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 应用程序部署为
"将应用程序执行为:": Me
,Web Apps 的脚本以所有者身份运行.所以使用了所有者的配额. - 如果将 Web 应用程序部署为
"将应用程序执行为:": 用户访问网络应用
,网络应用的脚本以每个用户的身份运行.因此使用每个用户的配额.
- 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 上的并发点击数或同时执行数是否有任何限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!