Hello,
if I run a Cloud Code timer every 15 minutes which is only retrieving a single record to identify whether to calculate new data or not is this counted as a single API request?
I am sure you are aware of this topic: my need is to balance script code execution time vs. number of requests/min. So, I run a script multiple times a day to update all my data within the script execution time. After x runs I do not need this anymore, but I cannot stop the timer for the rest of the day.
I am looking for alternative ways to optimize this, but not run into a cost trap.
Regards, Joerg
Hi @Jorg_Beyer
if the timer makes 1 API call at the end it should 1 call + 1 call for sending logs about running the cloud code (if you haven’t disabled logs)
The timer makes only 1 Database call and no API call if not necessary. So it should be only 1 Log Call? I can set the Log level only system wide, right?
yes,
and setting the log level to more than INFO should not send any info/debug requests
That is a good point. I am using far too often print messages, which I leave in the code just to see how it runs. Is every print counted as 1 Log message if I leave the Log Level at INFO?
Is every print counted as 1 Log message if I leave the Log Level at INFO?
No, it accumulates some number of messages (10 by default) and/or some time after the first message (I guess after 1 second by default) and then flushes it to the server
so if you have a few messages in sync flow they will be sent in one request
Ok, understand. Is this even the case if the 10 messages are distributed over 2 or 3 different APIs that are called one after the other?
well, it depends on how much time these API requests take
see the sending log messages policy after adding a new log message
- it checks if in the pool more than 10 messages it runs a flush process (sends all the messages to the server)
- if there are no 10 messages in the pool it runs a timer (1 second) and flushes all messages to the server even if there are 1 or 1000 messages
therefore if your case is:
- print a text
- run async code (duration less than 1 seconds)
- print a text one more time
it will be only one request
however, if:
- print a text
- run async code (duration more than 1 second)
- print a text one more time
it will be two requests
1 Like