5 Ways to Schedule Serverless Functions on Oracle Cloud Infrastructure

5 Ways to Schedule Serverless Functions on Oracle Cloud Infrastructure

There are many use cases where a scheduler is needed to make constant calls to a Function – maybe to keep that function alive for better response time, or maybe the function is a listener to the streaming service and you want to execute it every 30 seconds or so. Unfortunately, today, there is no way to schedule an execution of the Functions on Oracle Cloud Infrastructure.

As there’s no native way to do it, let’s take a look at some alternatives:

  1. CRON Job on OCI Compute Instance
  2. OCI Compute Autoscaling Schedule-Based
  3. OCI Health Check Service
  4. OKE CRON Job
  5. Integration Cloud

CRON Job on OCI Compute Instance

Now, this may seem like a bad example, certainly taking into account that we’re talking about Serverless Compute – it kind of defeats the purpose!

The reason why I still want to take this into account is that, maybe, like me, you have a development instance or a multi-purpose instance that is already there and you won’t be creating a Compute Instance just to run a CRON job that will execute a cURL request to the function’s endpoint. Just, make sure you don’t forget about your CRON Job and delete the instance.

This certainly is not the best alternative – but it something that does the job.

OCI Compute Autoscaling Schedule-Based

The OCI Events Service can be used to trigger Functions.

You could use the Scheduled-Based Autoscaling feature in the Compute Instances to trigger a Cloud Event, and the event will then trigger the Function. One downside to this alternative is that it can be used for a pattern of “every x minutes”, but not faster than this. For example, you cannot use it for a pattern of “every x seconds”, which would keep the Function alive.

This is one example of using the Cloud Infrastructure and the OCI Events service to trigger the Function. Other use cases may work as well.

OCI Health Check Service

This may be the best option for most cases as there’s no extra infrastructure needed, and it’s all in OCI. You can use the Health-Check Service that is available in OCI to make HTTP calls on a scheduled basis.

This means that the Function should be exposed via an API Gateway – that endpoint would be available for calls in the health-check service.  One downside of this option is that there is no way to send a body in the requests, but Headers can be specified.

Note: When using the HTTPS protocol, a TLS handshake is made, so you should add a Host header with the FQDN of the API Gateway as value. Otherwise, the calls may fail with TLS errors.

Check this article for a detailed explanation of the subject.

OKE CRON Job

This is a nice way of running OCI CLI commands automatically on a recurring base from an OKE Cluster. I will not go into detail on this example as there is already a great article written on the Oracle Cloud Nativ Blog. Please feel free to follow this link to the article.

Integration Cloud

If you already have Oracle Integration Cloud in your IT ecosystem, building a Scheduled Integration could do the trick just fine by calling the function’s endpoint, preferably exposed via an API Gateway, based on your scheduler configuration.

Conclusions

Until a native solution will be provided, you can use one of the methods above to make scheduled calls to the OCI Functions.

Of course, there are many other tools that can be used to trigger public API calls on a scheduled basis – like IFTTT.

Image Rights

Ionut Adrian Vladu

I enjoy building python scripts for…everything! I am a Cloud enthusiast and I like to keep up with technology. When I'm not behind a computer, I like taking photos -- Visit My 500px profile -- or sit back and enjoy Formula 1 race weekends. Currently, working as a Tech Cloud Specialist @ Oracle
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments