Posts

Top-6 frameworks for Java microservices in 2023

Feb 16, 2023
Dmitry Chuyko
13.8

Cloud-native microservices are a new norm, so if you are starting an enterprise project or looking to conquer new career heights, you need an ultimate toolkit to build resilient, highly-performant Java services tailored to the Cloud.

A framework provides a platform and necessary tools for you to develop applications without having to start from scratch and deal with extra logic. But there are so many frameworks on the market nowadays! How to select an optimal solution for your specific case? Should you go with good old Spring Boot or try new grounds? Let’s find out!

Spring Boot

Developer: Pivotal Software

Top advantages

Top disadvantages

Wide variety of production-ready solutions

Increased binary size

Easy to solve issues with large community and detailed documentation

Slower startup

Nested cozily in the Spring framework ecosystem, Spring Boot is the most popular project for building microservices among Java developers. It follows the “convention over configuration” approach, which aims to reduce the number of decisions developers have to make when using the framework. As such, Spring Boot

  • Offers numerous out-of-the-box tools for creating production-ready applications with minimal effort;
  • Configures the application automatically based on the added dependencies;
  • Comes with an embedded database and an HTTP server such as Tomcat, Jetty, etc., which minimizes the time required to set up an application. It also builds a single jar file with a web server, so the application is extremely easy to deploy; 
  • Supports annotations, thus eliminating the boilerplate code needed for XML configurations.

A large community thriving around Spring Boot and a comprehensive up-to-date documentation enable the developers to resolve issues quickly and find a ready solution for almost any query. In addition, Spring Boot recently received baked-in support for GraalVM Native Image — developers can now convert Spring Boot apps into native executables without additional configuration.

But at the same time, Spring Boot applications may be associated with slower startup and increased memory consumption. The resulting binaries may be bloated due to the inclusion of unnecessary dependencies. Moreover, the coin of Spring Boot modularity has another side: it takes effort to master the intricacies of the complex framework ecosystem. 

Quarkus

Developer: Red Hat

Top advantages

Top disadvantages

Kubernetes-native

Harder to solve issues due to smaller community 

Faster startup

 

Quarkus is a Java framework geared towards Kubernetes deployment. It follows the container-first approach, offering the solutions for efficient Cloud deployment:

  • Native support for GraalVM and OpenJDK Hotspot makes it possible to use either AOT or JIT compilation. AOT compiler uses aggressive dead-code elimination to include only the essential dependencies into the resulting native image. The build-time processing allows the framework to collect necessary metadata for better compilation;
  • Faster startup and lower RSS memory consumption thanks to build-time configuration (as a result of which the executable contains only classes utilized at run time) and minimal use of Reflection and dynamic proxies;
  • Convenient scaling in Kubernetes.

Quarkus was initially created for cloud-native microservices and serverless, so it utilizes only the Java libraries most relevant for these purposes. At the same time, it is built on top of Java EE standards and enables the developers to use enterprise APIs.

Another strong suit of this framework is the ability to use imperative and reactive development models in one application. Reactive frameworks and extensions used by Quarkus aid the developers in writing and managing asynchronous code for better resource usage.

On the other hand, Quarkus community is still growing, and it may be difficult to find help or advice on problems encountered. In addition, Quarkus doesn’t implement the full set of CDI (Contexts and Dependency Injection) features and has some Quarkus-specific APIs and non-standard features, which may lead to migration issues. For instance, CDI portable extensions are not supported, so you have to figure out how to write Quarkus Extensions.

Micronaut

Developer: Object Computing, Inc.

Top advantages

Top disadvantages

Build-in cloud support

Not so many options for caching, few build-in endpoints for monitoring

Build-time compilation for optimized memory consumption 

Not always easy to solve a problem due to gaps in documentation

Micronaut is tailored to cloud-native microservices by design, so numerous cloud features are natively integrated into the framework, including:

  • Several service discovery systems (Eureka, Consul, and ZooKeeper);
  • Distributed tracing and distributed configuration;
  • Kubernetes and major cloud runtimes support;
  • Client-side load balancing;
  • Serverless functions.

As far as memory consumption and startup are concerned, Micronaut uses AOT compilation to process the code at build time, which results in a smaller executable with accelerated startup. GraalVM is also supported, which, coupled with a special Micronaut AWS module, makes this framework a good match for AWS Lambda functions.

However, Micronaut offers limited options for caching and monitoring. In addition, it might take time to figure out how to work with the framework and deal with issues as the Micronaut community is quite narrow.

Dropwizard

Developer: Yammer

Top advantages

Top disadvantages

Minimalistic

No built in Dependency Injection

Excellent metrics functionality 

No freedom of choice due to limited amount of supported libraries

Dropwizard was designed specifically for the development of RESTful web services and microservices. In essence, it is a lightweight toolkit that includes a minimalistic set of tried-and-true Java libraries: Jetty, Jersey, JUnit, Liquibase, etc. As the official documentation states, Dropwizard “straddles the line between a library and a framework,” meaning that it provides essential performant implementation to quickly spin up a production-ready web service.

Moreover, Dropwizard integrates a powerful Metrics library that is sometimes integrated into projects utilizing other frameworks, even Spring Boot.

Just like Spring Boot, Dropwizard follows the “convention over configuration” approach, but does so even more zealously. As a result, developers don’t have much freedom of choice when choosing the tools for their application. Furthermore, Dropwizard doesn’t support dependency injection, which may be inconvenient for developers who are used to working with this traditional design pattern. Finally, Dropwizard is suitable for REST services only and doesn’t support SOAP. 

MicroProfile

Developer: Eclipse Foundation

Top advantages

Top disadvantages

Set of Jakarta EE/Java EE APIs

Can be confusing for novices

Frequent updates 

 

The MicroProfile project is aimed at optimizing Enterprise Java for microservices. It is not a framework, but rather a specification consisting of Jakarta EE/Java EE APIs that can be implemented by other frameworks, for instance, Quarkus or Open Liberty. With MicroProfile, developers can utilize industry standards to build resilient Java microservices, which are portable across MicroProfile-compliant runtimes. In addition, they can choose an implementation that suits their business needs, and then migrate to a different one without any issues.

MicroProfile developers strive to accelerate the evolution of Enterprise Java by integrating new functionality and updating existing APIs promptly. Therefore, MicroProfile enjoys a short release cycle to keep up with the innovations.

At the same time, working with Enterprise Java API may be quite challenging for a novice; plus one must understand the specifics of a selected MicroProfile implementation.

Vert.x

Developer: Eclipse Foundation

Top advantages

Top disadvantages

Comprehensive toolkit for reactive programming

Only for reactive programming

Lightweight and embeddable

 

Vert.x is a polyglot development kit for building reactive microservices. Reactive (asynchronous) programming can be complicated, so Vert.x provides a comprehensive technology stack that facilitates writing and maintenance of asynchronous code.

As it is not a framework, but a toolkit, it is very minimalistic and embeddable. Developers can integrate it into their project without changing the code structure. Other frameworks use reactive powers of Vert.x: for instance, Quarkus applies it to back its reactive programming model.

Most Vert.x APIs don’t block the calling thread, so the application can handle extensive volumes of concurrency without devouring the resources.

Given the asynchronous model of Vert.x, it is not suitable for any other type of application. Moreover, it takes a high level of expertise to write good asynchronous code even with Vert.x help, and badly implemented reactivity may even lead to performance deterioration. Besides, Java recently received its own highly efficient concurrency models in the form of virtual thread, which takes the burden of asynchronous programming off the developers’ shoulders.

Choosing a framework is only the first step towards the Cloud

Building cloud-native microservices is a complex task. Imagine you are actually sending your services into the clouds and beyond, where they should be able to efficiently scale to the size of a constellation. Framework is a toolkit for app development. What else do you need?

  • A launching platform — a reliable Java runtime. Oracle Java is the first option that comes to mind, but considering the recent licensing and pricing changes by Oracle, it would be more cost-efficient to select an OpenJDK distribution;
  • A spaceship — a perfect container for the application. It must be secure, fast, and small. The key component of a microcontainer is a Linux distribution. An overview of the most popular Linux distros for Server and Cloud can be found here.

We recommend you opt for Liberica JDK Lite optimized for Cloud, which matches perfectly with a lightweight Linux created specifically for the Cloud — Alpaquita Linux

Alpaquita is based on Alpine, but comes with several enhancements:

  • Two variants with optimized musl and glibc;
  • Three additional malloc implementation for various workloads;
  • Free-to-use Alpaquita Stream (rolling release) and enterprise Alpaquita LTS.

A detailed description of Alpaquita Linux is not within the scope of this article. Click the button below to download a white paper on Alpaquita OS where we explore technical characteristics and performance of this distro in-depth.

Download white paper on Alpaquita Linux

A container with Alpaquita and Liberica Lite is 72.54 MB. What is more, you can use JRE for running the apps — such a container takes up only 41.92 MB; it is the smallest container on the market!

Regardless of the framework you choose, BellSoft offers solutions compatible with any of them, so you can build a performant, resilient Cloud infrastructure and reduce TCO of Java apps by min. 20%!

Subcribe to our newsletter

figure

Read the industry news, receive solutions to your problems, and find the ways to save money.

Further reading