I am trying to evaluate Google Apps Script (GAS) as one of the component in my overall SaaS. But, I see there is quota limits.
https://developers.google.com/apps-script/guides/services/quotas#current_limitations
Can someone explain what "Simultaneous executions" stands for? Is it 30 Simultaneous executions per a script? Or 30 Simultaneous executions per an account?
I think it's per account. This is important when publishing web apps. When set to execute as "Me", you're limited to 30 simultaneous executions of all users, since they all run as "Me". But if set to execute as "user accessing the web app", then each user gets 30 simultaneous executions. Refer #Tanaike's answer
This also makes sense in case of add-on, where a single script project is published to execute as many users. If simultaneous executions of 30 applies per script, then a add-on could only have 30 users, which is certainly not the case.
Related Error messages from Google documentation:
Script invoked too many times per second for this Google user account. This indicates that the script began executing too many times in a short period. It most commonly occurs for custom functions that are called repeatedly in a single spreadsheet. To avoid this error, code your custom functions so that they only need to be called once per range of data, as explained in the guide to custom functions.
There are too many scripts running simultaneously for this Google user account. This indicates that you have too many scripts executing at once, although not necessarily the same script. Like the exception above, this most commonly occurs for custom functions that are called repeatedly in a single spreadsheet.
Notice both error messages end in "for this Google user account"
Comments from Google/Issuetracker links:
https://issuetracker.google.com/issues/168987850#comment6
https://issuetracker.google.com/issues/36764854#comment8
https://issuetracker.google.com/issues/144888046
https://issuetracker.google.com/issues/161091247#comment2
In almost all cases, Google representative says "for account". You may also create a new issue in the issuetracker for explicit documentation or clarification.
Related
I manage a large Google spreadsheet where I use apps script to automatically sort and format form responses by using time-based triggers.
This sheet and many more like it are owned by one google account, not the ones who manage the individual sheets.
I have noticed that the performance of my scripts is very inconsistent over time. One minute they execute in 10-30 seconds, then they keep timing out for 2 hours, just to then suddenly work again. This happens regardless of what the actual script is and whether it is run by a trigger or manually.
I know that one of the limitations of Apps Script is 30 simultaneous executions per user.
So my question is: Does that limitation apply to the owner of the apps script project or the one who set up the triggers and runs the scripts?
Because if it's the former, then maybe the reason for the performance issues is that there are dozens of sheets fighting over those 30 execution slots?
Quota call is attributed to the user running the script. The "user running the script"/the effective user is different in different circumstances. In case of
Instance
Whose quota?
Script editor "Run"
User at the keyboard
Menu "Run"/Button click
User at the keyboard
Simple triggers
User at the keyboard
Installable triggers
User who installed the trigger(regardless of who is at the keyboard)ref
Custom function
User at the keyboard
Webapp(execute as me)
User who installed the trigger(regardless of who is at the keyboard)
Webapp(execute as user accessing)
User at the keyboardref
Quota calls are not attributed to the owner unless the owner satisfies any of the above criteria.
Reference:
User identity/permissions
I have a google app script that execute the following actions:
Read a incoming webhook, write some information on a google spreadsheet, update a google contact and generates several outbound webhooks.
It takes aproximately 5 seconds to execute the whole script.
I would like to know how much times per day I can execute this script. I have seen the following web page but I am not sure in which feature my actions might fit, since there is no description of what those each feature means.
https://developers.google.com/apps-script/guides/services/quotas
Also I check in the google app script dashboard in hope I could find the current usage of my app script, but I only found that my script is execute 500 times per day for an average of 5 seconds per execution. In the future I am going to need to execute this app script more times, but I will like to know which is limit.
¿Where can I find my current app script consumption and which are the quotas for the features I am currently using?
As mentioned in the comments, Google Apps Script has a quota page that shows execution limits on various services.
Please note that you can get quota exception messages if you go near these limits but not go over them entirely.
Since you mentioned that you may need to execute your script more than 500 times a day, you might want to start optimizing your functions to take less time. You can start searching for resources on how to do this, for example in this post: Tracking total execution time Google apps script for an account
We use google scripts and google sheets heavily. Recently we noticed a significant slowness in running our scripts, in particular calls like SpreadsheetApp.Spreadsheet.getValues() and getRow() take 2-5 second for each tab in our google sheets, and we have over 50 tabs of data.
We noticed the slowness is for all users in our domain. However, if we login with our gmail accounts and run the script it is super fast, GetValues and GetRow return in milliseconds.
Any ideas what is happening? Is there some throttling of the domain going on? I don't see any alerts or errors anywhere.
Thank you
I have a Google Apps Script that is shared with another user (I own both users - one is my personal Gmail and one is my work account on Gsuite). The script scans threads in my inbox, and applies labels to the threads based on rules.
I set up time-based triggers from each user account to run the script.
The script calls Session.getActiveUser().getEmail() to identify which user is running it, and sets some parameters differently depending on the user.
Logging shows that, for either user, the script errors about half the time, intermittently, saying "The script does not have permission to get the active user's identity." (Clearly it DOES have permission, for each user, or else it would fail every time.)
To troubleshoot this, I stopped sharing the script between users. I made separate copies of the same code, in each user's account. Now the script is running fine for both users.
Can anyone confirm that this is a bug in Google's operating environment? That (I suspect) somehow the operating environment gets confused about which user is running the shared script?
(I did search this forum and can't find a description that explains it)
You should be using getEffectiveUser(), since there is not necessarily an active user when the time-based trigger triggers.
From the documentation (linked above):
If the script is running under an installable trigger, this returns
the account of the user who created the trigger.
I've spliced together a script which runs on a 1-minute interval and does a look-up on a Google label:
var mailthreads = GmailApp.search('label:MYLABEL');
Initially, the script ran fine, however within a few days the script began to throw a variety of errors, such as:
Service invoked too many times for one day: gmail
Service using too much computer time for one day
Service invoked too many times in a short time: gmail rateMax. Try Utilities.sleep(1000) between calls.
I have checked Quotas for Google Services with no real explination on what could be causing the script to fail - it ran initially day-to-day without fail, and as the cycle for quotas is 24-hours I would imagine if one 24-hour cycle worked, why didn't the rest?
One theory I have is that the GmailApp.Search query counts each returned item under the label as a single read, and now that the label has grown in size I am reaching a quota limit on reads. Is this how it works, and if not is there anything else I can check?