Functions in Oracle Cloud Infrastructure

What is Oracle Functions?

  • A fully-managed, multi-tenant, highly scalable, on-demand, Functions-as-a-Service platform.
  • Powered by the Fn Project β€” an open source, container native, serverless platform that can be run anywhere β€” any cloud or on-prem.
    • You can download & install the open source distribution of Fn Project, develop & test a function locally, & then use the same tooling to deploy that function to Oracle Functions.
  • Serverless & elastic architecture β€” No infrastructure or software administration.
  • Your app is highly-available, scalable, secure, & monitored.
  • You can write code in Java, Python, Node, Go, & Ruby, or bring your own Dockerfile, & Graal VM.
  • Deploy your code, call it directly or trigger it in response to events, & get billed only for the resources consumed during the execution.
  • You can invoke the functions you deploy to Oracle Functions using the CLI or by making signed HTTP requests.
  • A function’s request & response payload size is limited to 6 MB.

Oracle Functions Concepts

Functions Developers

  • OCI users who use Oracle Functions to create & deploy functions.
  • Functions developers must have OCI user accounts.

Applications

  • An application is:
    • a logical grouping of functions
    • a common context to store configuration variables that are available to all functions in the application
    • a way to ensure function runtime isolation
  • When you define an application in Oracle Functions, you specify the subnets in which to run the functions in the application.
  • When functions from different applications are invoked simultaneously, Oracle Functions ensures these function executions are isolated from each other.

Functions

  • Functions are:
    • blocks of code that generally do one simple thing
    • grouped into applications
    • stored as Docker images in a specified Docker registry
    • invoked in response to a CLI command or signed HTTP request
  • When you deploy a function to Oracle Functions using the Fn Project CLI, the function is built as a Docker image and pushed to a specified Docker registry.
  • A definition of the function is stored as metadata in the Oracle Functions server. The definition describes how the function is to be executed and includes:
    • the Docker image to pull when the function is invoked
    • the maximum length of time the function is allowed to execute for
    • the maximum amount of memory the function is allowed to consume

Invocations

  • A function’s code is run (or executed) when the function is called (or invoked).
  • A function can be invoked from:
    • The Fn Project CLI.
    • OCI SDKs
    • Signed HTTP requests to the function’s invoke endpoint. Every function has an invoke endpoint.
    • Other Oracle Cloud services (e.g. triggered by an event in the Events service) or from external services.
  • When a function is invoked for the first time, Oracle Functions pulls the function’s Docker image from the specified Docker registry, runs it as a Docker container, & executes the function.
  • If there are subsequent requests to the same function, Oracle Functions directs those requests to the same container.
  • After a period being idle, the Docker container is removed.

Triggers

  • A trigger is the result of an action elsewhere in the system, that sends a request to invoke a function in Oracle Functions, e.g., an event in the Events service might cause a trigger to send a request to Oracle Functions to invoke a function.
  • Alternatively, a trigger might send regular requests to invoke a function on a defined, time-based schedule.
  • A function might not be associated with any triggers, or it can be associated with one or multiple triggers.

How Oracle Functions Works β€” Deployment

When you run the Fn Project CLI command to deploy a function, the following happens in sequence:

  1. A Docker image is built from the function code.
  2. The image is pushed to the specified Docker registry.
  3. The function metadata is uploaded to the Fn Server.

The function metadata is derived from the function definition that a developer writes in a func.yaml file. It includes:

  • the maximum length of time the function is allowed to execute for
  • the maximum amount of memory the function is allowed to consume

How Oracle Functions Works β€” Invocation

When a function is invoked for the first time, Oracle Functions verifies the request with IAM. After the request passes authN & authZ, Oracle Functions then passes the request to the Fn Server, which uses the function definition to:

  • identify the Docker image of the function to pull from the Docker registry
  • execute the function by running the function’s image as a container on an instance in a subnet associated with the application to which the function belongs

When the function is executing inside the container, the function can read from and write to other resources and services running in the same subnet like Database as a Service. The function can also read from and write to other shared resources like Object Storage & other Oracle Cloud Services.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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