If I have hundreds of triggers set to work on a specific day of the week within the same hour time frame (lets say Monday between 8 am to 9 am) - will they be executed in the way that will burden the least on the server?
If not - according to which consideration the execution time will be determine?
Is there a limtation of amount of triggers in an hour/day? What is it? (in Quotas for Google Services I found only a Triggers total runtime).
Thanks!
Related
i currently have a google web app that takes a value then checks it against 14,0000 cells in a master google sheet. i've had the idea to break the function down into 14 functions that run simultaneously(each function searching 1000) therefore cutting the runtime from 6 seconds to below 1. The issue i am concerned about is the limit of 30 simultaneous functions running. this web app will be used by more than one person at a time so it needs to be able to do more than 30. My idea is to create an account for each user with a copy of the web app for each account, so that the simultaneous executions will stay around 14 for each user. so my question is this, Does google sheets have a limit to the amount of simultaneous read/write? any help is greatly appreciated.
If you can implement this I think there are no limits.
This version of the Google Sheets API has a limit of 500 requests per
100 seconds per project, and 100 requests per 100 seconds per user.
Limits for reads and writes are tracked separately. There is no daily
usage limit.
https://developers.google.com/sheets/api/limits
When I create a daily time-based trigger for the Google app script associated with my Google spreadsheet, I am prompted to select an execution time that is within an hour-long window, and it appears that a cron wrapper randomly assigns an exact execution time within that hour-long interval.
Because my application's specific use case has several data dependencies which may not be completed early in the hour, I was forced to divide my application into several stages, with separate triggers each delayed by an hour, to insure that the required data would be available.
For example, the trigger time that was initially assigned for my script was 6:03AM, but the data which usually arrived at 5:57AM, occasionally did not arrive until 6:10AM and the script had nothing to process for that day. As a blunt force solution, I deleted the 6-7AM trigger and re-created it to execute in the 7-8AM time slot to insure the required data was available. This required that the second stage of the script had to be moved to 8-9AM, resulting in script results which could be delayed by as much as 2-3 hours.
To improve this situation, I am contemplating integrating the two script processing stages and creating a more accurate script execution trigger time, say 6:30AM to be safe. Does anyone know if:
Is it possible, other than by observing daily processing, to discover the exact trigger execution time that has been assigned, and
If randomly assigned, can script triggers be created and deleted until an acceptably precise execution time is obtained?
Thanks in advance for any guidance provided.
If accuracy is paramount, you can forgo using apps script triggers altogether and leverage a 3rd party tool instead.
I'd recommend using cron-job.org. This service can create cron jobs that make POST requests to a url endpoint you specify, and you can schedule times accurate to a minute. To use it with Apps Script implement a doPost() to handle post requests and deploy your script as a Web APP. You then create a cron job using the service and pass it the web app's URL as an endpoint.
The cron job will fire at the scheduled time and you can perform any requisite operations inside the doPost() in response to the incoming POST request.
Thank you to random parts and Dimu Designs for the guidance. Based upon experimentation, here are the answers to my questions:
Is it possible, other than by observing daily processing, to discover the exact trigger execution time that has been assigned? Answer: No way except by observing the random trigger time assigned within the requested hour window.
If randomly assigned, can script triggers be created and deleted until an acceptably precise execution time is obtained? Answer: Yes. I adjusted my script's assigned execution time by observing a trigger's execution time (via email message timestamp), and deleting, recreating, and observing the randomly assigned trigger execution time until I got an acceptable minute within the requested hour window.
I'm running some scripts on a daily bases in a spreadsheet, at this point I have two scripts running and both have to be triggered at same time (7am to 8am) but I need the script GeraPDF comes first. How do I define the priority of triggers when the events are the same?
You can't put a priority for two trigger when they've got the same day timer, cause Apps script is choosing the moment between 7am and 8am where your script gonna run (see here).
A time-driven trigger (also called a clock trigger) is similar to a
cron job in Unix. Time-driven triggers let scripts execute at a
particular time or on a recurring interval, as frequently as every
minute or as infrequently as once per month. (Note that an add-on can
use a time-driven trigger once per hour at most.) The time may be
slightly randomized — for example, if you create a recurring 9 a.m.
trigger, Apps Script chooses a time between 9 a.m. and 10 a.m., then
keeps that timing consistent from day to day so that 24 hours elapse
before the trigger fires again.
If you want to put a priority, you should put the day timer one hour early.
I've created a time driven trigger that would run the main function of my Google-apps-script. every 5 minutes (Gmail)
It's working fine, but I received the "Summary of failures" with the error message " Service using too much computer time for one day " 7 times.
So my question is, I'm I allowed to set the time driven trigger to run my script every 5 minutes ?
As mentioned in the documentation there is a maximum of 1 hour computing time for normal gmail account.
See reference here.
So I got the error message in the subject on the 1 (one) script I had running yesterday and I am assuming I will get a similar message today.
I have improved the script (which has a trigger to run once per minute) so it functions more along the lines of how it is supposed to however the error message got me thinking as to what sort of functions or bits of programs might be asking for more service time than others.
For example, I have had to use multiple sleep calls in my google apps script to allow the data import to run and again for the worksheet changes/copy paste calls to process. Are all those sleep calls counting against me in terms of service time used?
I would ask on the community's behalf that this be left as an open ended question not specific to the sleep function. What sorts of parts of a script are demanding service time and which are not (if any).
Every call to a service (Spreadsheet, Calendar or whatever) takes more time than regular JavaScript operations.
For example, if you have to modify 10 cells in a Spreadsheet,
calling range.setValue() 10 times takes far more time than having all the data in an array and then updating the spreadsheet in one go using range.setValues().
If you can paste pieces of your code, the community will be able to offer more advice on how to improve your script.
The limit is on CPU time used in time based triggers, and I believe those sleep calls are counted against your limit. I'd encourage you to find ways to avoid the sleep calls, or schedule your script to run less often.