Using OCI Monitoring Healthchecks to Schedule execution of Serverless Functions on Oracle Cloud Infrastructure

Lucas Jellema 1
0 0
Read Time:2 Minute, 24 Second

Execution of scheduled jobs based on a time schedule is a frequent requirement. Jobs on Oracle Cloud Infrastructure are often implemented using cloud native, serverless Functions – that can be exposed through (public) HTTP endpoints on an API Gateway. I recently published an article describing how execution of functions can be scheduled using IFTTT. This works fine. However, there is a much better way – that is finer grained, easier to monitor and completely cloud native on Oracle Cloud Infrastructure.

Using the OCI Monitoring Service we can create Healthchecks that consist of periodic ping or HTTP calls. We can configure a Healthcheck that periodically invokes an endpoint on a public API Gateway with a Function as its backend. In this way we can easily schedule a function to be executed every X seconds | minutes | hours | days. The following figure describes this setup.

image

The hello function shown in this figure was created in an earlier article; it is implemented in Node and does not do anything useful. There are no requirements on the backend function that we want to schedule the execution of.

The steps we go through:

  • define a Health Check in OCI Monitoring for the API Gateway endpoint & route for the Function we want to schedule
  • (check that the function is now periodically triggered)

Note: the Health Check does not allow us to pass a body to the function; HTTP headers can be specified.

To create a Health Check, go to Monitoring | Health Checks:

SNAGHTML4dae7d68

Click on Create Health Check:

image

Configure the Health Check – using the API Gateway endpoint and the [URL] path on APU Gateway to the function to be triggered. Indicate how often the health should be checked; this corresponds with the frequency of triggering the function.

SNAGHTML4db613ba

The health check shown here fires every 60 seconds; it then makes a GET call (HEAD is the other option) over HTTPS to the API Gateway’s endpoint at the path /fn/hello – which leads to the functin hello. No headers are included in the request.

Save the new Health Check Configuration. It should now immediately be activated.

After a few minutes, the console shows the following details for the Health Check – evidence it has (successfully) been executed:

image

The detailed metrics after 45 minutes give some insight in the latency on the calls to the function. I expect the peaks to be caused by the function going cold after a little while, causing a much longer response time when invoked after the cold restart.

image

I probably should investigate this in more detail.

On the function side, we can see in the metrics that the function is regularly executed, about once a minute.

image

Using a Health Check – together with an API Gateway – seems a fairly elegant way of scheduling function execution. Oracle is likely to provide scheduling as a cloud native function in the near future, but until then, this seems a workable alternative.

About Post Author

Lucas Jellema

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Kubernetes & Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press book Oracle SOA Suite 12c Handbook. Frequent presenter on user groups and community events and conferences such as JavaOne, Oracle Code, CodeOne, NLJUG JFall and Oracle OpenWorld.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

One thought on “Using OCI Monitoring Healthchecks to Schedule execution of Serverless Functions on Oracle Cloud Infrastructure

  1. When I try this setup I cannot select the API GW endpoint, it shows the public IP. When using the ip the health check fails with the message “errorMessage”: “x509: cannot validate certificate for XXX.XXX.XXX.XXX because it doesn’t contain any IP SANs”,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Next Post

OCI Serverless Functions invoking other Functions - synchronous and asynchronously through API Gateway and Streaming

OCI allows for cloud native application development, using facilities such as serverless functions, a light weight API gateway, a streaming service for asynchronous communication based on event messaging and built-in monitoring. In previous articles, I have gone over several aspects of serverless functions and API Gateways to create and expose […]
%d bloggers like this: