In this blog, we will build a Java serverless application using the fn project on JVM and then on GraalVM and compare the performance.

Function-as-a-Service or Serverless is the most economical way to run code and use the cloud resources to the minimum. The serverless approach runs the code when a request is received. The code boots up, executes, handles the requests, and shuts down. Thus, utilizing the cloud resources to the optimum. This provides a highly available, scalable architecture, at the most optimal costs. However, serverless architecture demands a faster boot, quicker execution, and shutdown.

GraalVM native images (ahead of time) is the best runtime. GraalVM native images have a very small footprint, they are fast to boot and they come with embedded VM (Substrate VM).

I had blogged about GraalVM here. Please refer to the following blogs, for better understanding of the architecture of Graal VM and how it builds on top of Java Virtual Machine

**Episode 1: “The Evolution” ** - Java JIT Hotspot & C2 compilers (the current episode…scroll down)

Episode 2: “The Holy Grail”  - GraalVM

In these blogs, I will talk about how GraalVM embraces polyglot, providing interoperability between various programming languages. I will then cover how it extends from Hotspot, and provides faster execution, and smaller footprints with ‘Ahead-of-time’ compilations and other optimizations.

fn Project

fn project is a great environment to build serverless applications. fn supports building serverless applications in Go, Java, JavaScript, Python, Ruby, C#. It is a very simple and rapid application development environment that comes with an fn daemon and a CLI which provides most of the scaffolding to build serverless applications.

In this blog, let’s focus on building a simple KG to Pounds converter function in Java. First, we will build a serverless application with Java, and then later build it using GraalVM native image. We will then compare how fast and small GraalVM implementation is.

#tutorial #performance #docker #serverless #container #kubernates

Java Serverless on Steroids With fn+GraalVM Hands-On
1.25 GEEK