Serverless Functions
Serverless functions are at the pinnacle of building scalable and distributed business logic implementations. They are called serverless simply because the server and its runtime environment are fully managed by the cloud vendor and are not exposed to the application developer. The essential idea is to create functional units of business logic that can be packaged and executed in isolation. These are generally focused, well-defined tasks such as file processing, in which a file is read from a source, minimally processed or transformed, and then either sent to a destination or takes an action in response to an event. Functions also find use in Internet of Things (IOT) applications, image processing, machine learning (ML) inferencing, and other applications. Functions usually do not exist in isolation; many times, they are chained together to create a network of functions (similar to microservices in that respect) that interact with external systems. Functions are usually time bound: They are expected to finish their execution within a slice of time, beyond which they can be terminated. In many cases, functions are also event driven. Their fundamental design of running small, time-bound processes that perform well-defined actions makes them naturally scalable and distributed when assembled into larger systems. Functions can be written in Python, Go, Java, NodeJS, and other commonly used programming languages and runtime environments. Functions should be fully self-contained and cannot depend on any outside software or code to operate other than calling other APIs. Being packaged into these self-contained units allows them to start up, execute their functionality, and then shut down quickly. Functions abstract all infrastructure management from their users, and a cloud platform (such as OCI) guarantees a secure execution environment that can scale quickly as the calls to the function increase. This also means that functions follow a very different cost model based on actual usage rather than the typical infrastructure that might be billed based on resources allocated.
Oracle Functions is a fully managed Functions-as-a-Service platform that is built on enterprise-grade Oracle Cloud Infrastructure and powered by the Fn Project open-source engine. The serverless and elastic architecture of Oracle Functions means there is no infrastructure administration or software administration for you to perform. You do not provision or maintain compute instances, nor are you responsible for operating system software patches and upgrades. Oracle Functions simply ensures that your app is highly available, scalable, secure, and monitored. With Oracle Functions, you can write code in Java, Python, Node.js, Go, and Ruby (and, for advanced use cases, bring your own Dockerfile and Graal VM). You can then deploy your code, call it directly, or trigger it in response to events, and you get billed only for the resources consumed during the execution.
Oracle Functions is based on Fn Project.4 Fn Project is an open-source, container-native, serverless platform that can be run anywhere—in any cloud or on-premises. Fn Project is easy to use, extensible, and performant. You can download and install the open-source distribution of Fn Project, develop and test a function locally, and then use the same tooling to deploy that function to Oracle Functions. You can access Oracle Functions using the console, a Command Line Interface (CLI), and a REST API. You can invoke the functions you deploy to Oracle Functions by using the CLI or by making signed HTTP requests. Oracle Functions is integrated with Oracle Cloud Infrastructure Identity and Access Management (IAM), which provides easy authentication with native Oracle Cloud Infrastructure identity functionality.
When you have written the code for a function and it is ready to deploy, you can use a single Fn Project CLI command to perform all the deploy operations in sequence:
Build a Docker image from the function.
Provide a definition of the function in a func.yaml file that includes:
The maximum length of time the function is allowed to execute
The maximum amount of memory the function is allowed to consume
Push the image to the specified Docker registry.
Upload function metadata (including the memory and time restrictions and a link to the image in the Docker registry) to the Fn Server and add the function to the list of functions shown in the console.
Figure 3-8 shows how the Functions CLI interacts with the various components to deploy a new function.
FIGURE 3-8 The Components of Oracle Functions