Java serverless functions with Quarkus

The serverless journey started with functions - small snippets of code running on-demand and a short period in Figure 1.  AWS Lambda in the “1.0” phase made this paradigm very popular, but it had its limitations around execution time, protocols, and poor local development experience.

Since then, developers realized that the same serverless traits and benefits could be applied to microservices and Linux containers. This leads us into what we’re calling the “1.5” phase in Figure 1. Some serverless containers here completely abstract  Kubernetes, delivering the serverless experience through an abstraction layer that sits on top of it, like  Knative.

When we achieve this “2.0” phase in Figure 1, the serverless becomes to handle more complex orchestration and integration patterns, combined with some level of state management. More importantly, developers desire to keep using a familiar application runtime, Java, to run a combination of serverless and non-serverless workloads in legacy systems.

Figure 1. Serverless Journey

So what is the first task for Java developers before they get started with developing new serverless functions along with this journey? That should be to choose a new cloud-native Java framework that allows developers to run Java functions quicker and smaller memory footprint than traditional monolithic applications. This capability can also be applied to various infrastructure environments from physical servers to virtual machines, and containers in multi and hybrid cloud.

Developers might think of an opinionated  Spring framework that uses java.util.function package in  Spring Cloud Function to support imperative and reactive functions development. Spring also enables the developers to deploy Java functions to common Function as a Service (FaaS) services such as  Amazon Lambda,  Apache OpenWhisk,  Microsoft Azure, and  Project Riff using cloud adaptors. However, the developers still have concerns about slow startup and response time, and heavy memory consuming processes with Spring characteristics. This problem can be worse for running Java functions on scalable container environments like Kubernetes.

To solve this problem, I’d like to bring up a new open source cloud-native Java framework,  Quarkus that aims to design serverless applications and write cloud-native microservices to run on cloud infrastructures Kubernetes and  Red Hat OpenShift Container Platform.

Quarkus rethinks Java and uses a closed world approach to building and running it and has turned Java into a runtime that’s comparable to Go. Quarkus also includes 100+ extensions for developers to integrate enterprise capabilities from database access to serverless integration, messaging, security, observability, and business automation.

Here is a quick example of how developers can scaffold a Java serverless function project with Quarkus.

1. Creating the Quarkus AWS Lambda maven project

2. Building Serverless Functions

3. Deploying the Functions to AWS Lambda

4. Testing the Functions on AWS Lambda

#java #aws #serverless #microservice #lambda #quarkus

Getting started with Java Serverless Functions using Quarkus and AWS Lambda
1.35 GEEK