Not many developers are eager to go serversless with Java. It’s earned a reputation for being too slow. But as solution architects Michael Strydom and Julian Exenberger explain, that’s all old news. With the right optimizations Java can run just fine serverless, for example on Lambda. And as icing on the cake, you can use Quarkus to build the fastest serverless Java apps in no time.
The reason Java doesn’t work as well on serverless platforms is mainly because of the slow start-up time. It’s ideal for traditional client/server computing, where a single Java Server program performs thousands of user requests and optimizes the start-up as much as possible. That makes it start up slow, but then everything goes extremely fast. Serverless applications on the other hand may need to run thousands of stand-alone Java programs, each with its own user request. That’s when you notice Java’s slow start-up time for each request for the serverless platform.
Fortunately, you can solve Java’s speed problem on serverless platforms with just a few simple changes. We’ll explain how using the example of AWS Lambda. On that platform, the various phases of the life cycle run at different speeds. By changing how Java collaborates with the serverless life cycle, you can potentially achieve a dramatic boost in performance. How? By utilizing the various speeds of the life cycle to improve overall performance.
You can also continue to optimize by changing how you write Java apps. That’s because with serverless, we don’t always need the overhead for popular development frameworks, like Spring. They can help with managing complex programs, but they also increase the resource requirements and the start-up speeds of Java programs. And the many alternatives to Spring now available thanks to Android make more efficient and simpler programs possible. Take Google’s Dagger framework, for example, which is conceptually comparable to Spring but works much better for smaller applications, and is much faster.
Quarkus is another framework that’s suitable for building fast serverless Java apps, which is an area where Java had been losing until recently. Why? Java wasn’t able to keep up with Kubernetes and the rise of cluster management with lightweight applications. Newer script languages also offered more options for server-side and client-side developments. And single-threaded apps like Node.JS were no longer a problem, because Kubernetes can manage multiple single-threaded applications. That was a big setback for multi-threaded applications like Java.
Java also experienced other problems on Kubernetes; especially the size of the artifacts after build and the time it took to roll out apps. And don’t forget the infamous garbage collection problem, which made it impossible to conduct a garbage collection at the moment of your choosing. And if you did manage to do one, it didn’t help very much. So Java virtually disappeared from the scene. Only with the later patch version of Java 8 (after patch 153) were most of the problems solved with the integration of Java and Kubernetes. All but one, in fact: the deployment artefacts were still too large.
In 2019, Red Hat found an answer with their open-source platform Quarkus. Red Hat wanted to make Java small and light, and ensure that Java development of serverless apps was fun and easy. To that end, Quarkus offers expansive libraries and standards, and combines imperative and reactive coding. That’s how Red Hat solved problems like Java’s cumbersome size.
Quarkus is also easy to master. You can quite literally configure it in just one day. I (Michael) use Quarkus now for integrations and reports, to take work out of my team’s hands. With Quarkus, I can build Springboot APIs, Apache Camel integrations and OpenTelemetry in no time. And one great benefit is that you don’t have too much to choose from with Quarkus; instead of having thousands of ways to write code, they’ve chosen the most useful method. Quarkus is also open source, and the community is constantly improving the platform.
So we can now officially announce: Java’s rusty reputation is a thing of the past! Java is now revving its engines to get started with serverless. Spread the word.
In this talk, you’ll immerse yourself in Java in a cloud-native world. In their Tech Talk, Julian and Michael will explain exactly how you can optimize the collaboration between Java and your serverless platform. And what Quarkus has to offer you as a Java developer.
Julian is a software architect at Capgemini with a passion for technology. He’s worked in everything, from Java and VB to Objective-C and Ruby-on-Rails. Recently he’s grown to become a serious Kotlin afficionado, a cloud-native development veteran and a Lean groupie. When he’s not working at his computer, you can find him reading, writing, doing woodwork or simply spending time with his family.
Michael is also a software architect at Capgemini. He has a wealth of experience with system integration, SOA patterns, and of course Java. In his free time, he also experiments with the cloud, IoT, automation, robotics and Raspberry Pi. He has a soft spot for anything related to back-end, and leaves the front-end work to those who like selfies and man-buns.