Exception: Service invoked too many times for one day: premium urlfetch - google-apps-script

I have some scripts with functions running on a trigger. Some functions are scheduled to run once per day and few every 10 mins.
I am using a Google workspace account which has a quota of 100,000 calls/day for Urlfetch. I am quite sure that I haven't exceeded this quota. So, not sure why I keep getting this exception.
Exception: Service invoked too many times for one day: premium urlfetch.
Also, this exception comes for about an hour every day after which it resolves.
Please advise on the following :-
Root cause and resolution
Difference between urlfetch and premium urlfetch (as the exception says premium)

Related

How do I restart a failed Google Apps Script Trigger?

I have a lot of time-driven triggers that query my Cloud SQL server and update information in Google Sheets.
Today, I went over my daily quota and got the following error message:
Jun 9, 2020, 7:37:11 AM Error Service invoked too many times for one day: premium jdbc connection.
All of my triggers stopped firing at 7:40 am. It's now 1pm. I can manually run all of my functions, and they finish without errors. However, I've deleted and re-created triggers, and no triggers will run on my account. Do I need to wait 24 hours? Is there somewhere else I can reset triggers? Do I need to create a new Apps Script Project?
As mentioned in comments, I waited until the rolling 24-hour quota refreshed (it was less than 24 hours). The quota I was maxed out on seems to be a rolling 24-hour Usage Time, so it doesn't reset to zero, it just gives you additional Usage Time as old usage rolls off.
Helpful suggestion in comments - Create a master script to add/remove all triggers, calling the other scripts as libraries. This allows you to quickly Delete all triggers, wait for the quota to reset/refresh, and add triggers back slowly or all at once. Otherwise you may have Triggers that continually fire as soon as your quota has room, thereby maxing out your quota again.

Google Apps Script "Service using too much computer time for one day" Error

I have begun to get this error just this week. I checked My Executions on Google Apps Script dashboard. But I do not see any scripts that are taking anywhere near the quota of Triggers total run time, which is 90 min / day for consumer accounts. This error tends to happen near midnight pacific time. So I am thinking near the end of the 24 hour quota period. Does anyone know what recent change Google has made that is causing this error? If I knew what Google changed, I could adjust my scripts to avoid the error.
I checked some other answers but they were not helpful because this seems to be a recent change that Google made.

What is the daily limit of manually executed google script?

In the documentation for developers (here) written about this error
Service using too much computer time for one day
that
This indicates that the script exceeded the total allowable execution time for one day. It most commonly occurs for scripts that run on a trigger, which have a lower daily limit than scripts executed manually.
And there is a daily limit for triggers total runtime (1hr for basic account).
But where can I get the limitation for manual executed script?
I'm pretty sure the limit is the same regardless of whether the script is manually executed or executed from a trigger; the limit is simply applied to your account, however you run the script.
As mentioned here: "Daily quotas are refreshed at the end of a 24-hour window; the exact time of this refresh, however, varies between users." I don't think Google publicly announces exactly what you get.
I run script on the sidebar that request calculation on the server side which stops after 300 seconds and the sidebar starts it again. This engine worked more than 12 hours without any fails. So, I suppose that there is no any limit for 'manually' executed scripts.

Is Google map geocoding limited to 2500 per day or per 24 hours?

Does anyone know if the limit touches an entire day or a period of 24 hour starting from the first request you do and until tomorrow at the same hour in the day?
Example:
I make 2500 request today from 14h00 to 19h00.
Result:
Tomorrow at 2h00AM I will be able to make more request?
OR
I have to wait until 19h00 tomorrow before I can make more request?
Thank you.
According to the documentation, the usage limits are :
Users of the free API: 2,500 requests per 24 hour period.
Maps for Business customers: 100,000 requests per 24 hour period.
We are speaking about a 24 hour period, so in your example, if you make 2500 requests from 2PM to 7PM, you won't be able to do any request since tomorrow 7PM.
I found another page where they talk about the rate and daily limit.
Usage Limits for Google Maps API Web Services
Sending too many requests per day. Sending requests too fast, i.e. too
many requests per second. Sending requests too fast for too long or
otherwise abusing the web service.
If you exceed the usage limits you will get an OVER_QUERY_LIMIT status
code as a response.
This means that the web service will stop providing normal responses
and switch to returning only status code OVER_QUERY_LIMIT until more
usage is allowed again. This can happen:
Within a few seconds, if the error was received because your
application sent too many requests per second.
Some time in the next 24 hours, if the error was received because your application sent too many requests per day. The time of day at
which the daily quota for a service is reset varies between customers
and for each API, and can change over time.
Upon receiving a response with status code OVER_QUERY_LIMIT, your
application should determine which usage limit has been exceeded. This
can be done by pausing for 2 seconds and resending the same request.
If status code is still OVER_QUERY_LIMIT, your application is sending
too many requests per day. Otherwise, your application is sending too
many requests per second.
On the same page there is also a video.
:-)
Maps API for Business: Using the v3 Geocoding API
Update: The limit is now 5000 queries per day for the free tier.

How comes my script fails to run while executed by a trigger but is successful when executed manually?

I'm not sure if I have encountered with a bug or is just me not fully understanding how triggers work, probably the second one :D.
I have a google apps script that collects information through a series of requests to our CRM's API and puts it on a Google Docs Spreadsheet, the script takes a while to run, however, it runs successfully (I run it manually every morning, takes about 3 minutes). But when I try to automate that task, I get an error message saying my script exceeded its execution time limit.
I tried setting up my triggers manually, creating them within the script, breaking down my script reducing the number of API requests (taking less then a minute to execute) and execute it several times so I get the whole information. Every single time I get the same error message.
Am I missing something here? Any help will be much appreciated!
Edit: The mail I received has this error message: "Exceeded maximum execution time".
Edit2: I was able to fix this (party). I came across the answer for this question Exceeded maximum execution time in Google Apps Script and worked like a charm.
There are some limits to Google Apps Scripts that you must keep in mind: see Quotas.
It is possible that you are exceeding your total runtime for Triggers. There is also the shorter individual execution time limits on Triggers. I think I remember reading somewhere that Triggers have a lower total execution time limit per execution, but I can't remember where I saw it, and I can't find a source, even in Google's documentation.
This SO question is also similar...
I wouldn't say it's a bug, however as my own painfully experience, I can tell it's not the same running the script manually than through a time-driven trigger.
Sometimes it's just slower, but others it fails for timeout.
I don't know your specifics (there is no code available), but I would recommend you to use a retry exponential backoff function wrapping any critical call and also check for a timeout warning (let's say at 5 minutes) within the main loop.