I know, This should have better be patented by GCP or AWS. But man, Microsoft claimed this opportunity and won me as an employee.
I came up with this idea in my first week at Microsoft. Afterward, I’ve learned how to patent through the company portal and the patent was filed – MS# 406201-US-NP.
The Problem
I wanted to use the serverless azure function to crawl data on a periodic basis. However, The problem is that computing tier can be expensive with a timer trigger. if the client is flexible with the execution time, it is possible to use the lazy timer in order to save additional costs by minimizing the scaling out.
The Idea
The idea behind this flexibility is to start the execution in a near-optimal time while sticking to the constraints of the schedule, with the purpose of minimizing heavy loads magnitude and duration due to overlapping executions.
High load peaks could result in scaling out the computing instance which will cost the cloud customer and the cloud provider more money. Utilizing the current computing power accordingly without wasting additional resources due to stringent usage would benefit both the customer and the provider.
The Lazy Function niche
The lazy function comes in handy for users that are flexible with regard to the exact timing of execution in a given interval. For example, a cloud service that runs once every minute/hour may be willing to deviate from the exact time by 5 seconds/minutes.
Scenario
Let’s assume that we have a cloud function which runs every T seconds. The azure function execution takes more than T seconds to finish. Let’s also assume it takes 1.2T seconds to finish.
If the first execution started at t=0, then, according to the regular time triggered function, the second execution starts at t=T. Therefore, we would expect a high peak at t=T as we have two instances that are running simultaneously with overlapping executions. If the user is flexible regarding the start of the execution, then it would be optimal to start the execution of the second scheduled cloud function on t= 1.2T+ε as the load would be lower.

The lazy time triggered function can be configured by the customer to execute with an interval of T seconds between every two executions and some deviation at each execution. The deviation can either be defined additively (i.e., T ± Δ, where Δ > 0) or multiplicatively (i.e. (1 ± α)T, where α > 0).
Choosing the point in time within the defined permitted time period, in which a function should start execution, aims to minimize the overall magnitude and duration of heavy loads. We present two methods by which this can be accomplished.
Based on a predefined probability distribution function
We define a probability distribution function that assigns a probability to whether to start the execution in any permitted point in time based on the improvement in load. This probability distribution is defined between T- Δ and T+ Δ, such that for any percentage of improvement from the load at T- Δ, it assigns a probability of starting the execution. This function should assign the probability 1 at T+ Δ. The following figure shows examples of such functions:

Great work you have done.
LikeLike
I am not sure how pricing works in Azure but in AWS you are priced by execution time and resources utilized. It makes no differences whether you run 1000 invocations at the same time or one after the other
LikeLike
Hi Emi, thank you for commenting.
with azure, the charge includes also the computing plan that the customer chooses. When autoscaling, the customer will pay more. The goal of the patent is to stop unnecessary scaling when possible.
LikeLike