Estafet consultants occasionally produce short, practical tech notes designed to help the broader software development community and colleagues.
If you would like to have a more detailed discussion about any of these areas and/or how Estafet can help your organisation and teams with best practices in improving your SDLC, you are very welcome to contact us at firstname.lastname@example.org
“Microservice” was a big buzzword back in the early/mid 2010s and now, more than a decade since the term was coined, we can safely say that it’s one that has lived up to the hype. Microservice architecture refers to an approach in software design where applications are developed as a collection of small loosely-coupled autonomous services, each one implementing a specific business capability. When done appropriately, microservices can help immensely with addressing the shortcomings of monolithic applications and can bring many benefits:
- Different components of the codebase can be updated and deployed independently without the need to rebuild an entire large-scale application, leading to a faster development process and time-to-market
- Services that require more computing power and resources can be horizontally scaled individually without the need to vertically scale out the whole application
- If a single service crashes or becomes unavailable, it will not disrupt the entire system, leading to improved fault tolerance and resiliency
Speaking of programming languages, Java is one of the most popular choices when it comes to creating microservices. According to JetBrains’ 2022 annual Developer Ecosystem Survey taken among more than 29,000 developers, 34% of respondents who develop microservices use Java, making it the most preferred microservice programming language:
34% of respondents who develop microservices use Java as a programming language
You might think that Spring Boot is the de-facto standard for building Java microservices, but there are actually many frameworks available that can save valuable time and ease the development process. In this tech note, we will look at 5 such frameworks for implementing Java microservices and explore their features, strengths and weaknesses. By the end of reading this, you will have a better understanding of which framework is best suited for your future projects based on your specific requirements and constraints.
5 Java Frameworks for Building Microservices
Spring is top of the list of frameworks for creating Java microservices and applications in general. The Spring Framework is an open source project that was first released in 2002 and has become very popular in the Java community. Many Java developers are familiar with and use Spring’s “convention-over-configuration” solution Spring Boot. As its name suggests, Spring Boot makes it easy to quickly “bootstrap” and immediately run a Spring-based Java application. For microservices specifically, developers can also leverage tools from Spring Cloud – another project in the Spring ecosystem, which focuses on facilitating ready-to-run common patterns in distributed systems like service discovery, distributed tracing, load balancing and many more.
The list of Spring Boot features is a large one, but some of them are:
- Ability to leverage all of Spring’s core functionalities like dependency injection, validation, SpEL (Spring Expression Language), AOP (Aspect Oriented Programming), etc.
- Extremely quick project set-up by using the Spring Initializr, which is also built-in as a wizard inside some IDEs like IntelliJ IDEA Ultimate
- Spring Boot uses an embedded server model (Tomcat, Jetty or Undertow), making your microservices immediately production-ready
- Simplified data access to a vast variety of data stores with Spring Data, which includes support for JPA, JDBC, MongoDB, Elasticsearch, etc.
- Authentication, authorization and other security features with Spring Security including OAuth2, session management, etc.
- Observability with Spring Boot Actuator, which provides endpoints for monitoring service health, auditing and metrics gathering
- Access to numerous tools from Spring Cloud that are specifically tailored to microservice and cloud environments including: Spring Cloud Config for externalised configuration in distributed systems, Spring Cloud Sleuth for distributed tracing, Spring Cloud Stream for event-driven microservices that need to communicate via messaging systems, etc.
- Spring Boot is very accessible: it has a very large open source community, excellent documentation with included tutorials and lots of development resources
Of course, Spring Boot has some disadvantages as well:
- Since Spring Boot is designed to get your application up and running immediately, you might end up with a lot of unneeded dependencies, which results in a larger deployment file
- Spring Boot follows the “convention-over-configuration” approach and the way some components are auto-configured might restrict your flexibility over them
- Start-up time and memory footprint of Spring Boot services are generally higher than those of more lightweight frameworks (although Spring supports GraalVM Native Image which can be utilised to reduce resource usage)
- Uses its own APIs and does not implement standards like Eclipse MicroProfile
Microservices built with Spring Boot can start out small and iterate fast, making it a perfect framework for agile environments. The Spring ecosystem has been around for more than two decades, it has gained maturity and has an enormous community – if you meet a Java developer, chances are that they will already know or will at least have heard of Spring Boot. With the convenience and many out-of-the-box features it offers, Spring Boot is adopted by a wide range of users: from start-ups and SMEs to large and globally well-known companies like Netflix, Udemy, Trivago, Walmart and many others.
Oracle Helidon is an open source collection of Java libraries for writing microservices which is cloud-native, provides fast start-up time and low memory consumption. Helidon is a fairly new microservice framework which first came out in 2018 and has since seen several major releases. Helidon comes in two “flavours” that offer different development experiences: Helidon SE and Helidon MP. Helidon SE exposes Helidon’s foundational set of APIs and employs a very transparent “pure Java” development approach with “no magic” happening behind the scenes. On the other hand, Helidon MP offers a developer experience similar to Spring Boot or Jakarta EE with heavy usage of dependency injection and annotations. Users whose main goal is performance and whose applications heavily rely on concurrency are encouraged to use Helidon SE; users who are familiar with Spring Boot or Jakarta EE are suggested to use Helidon MP.
Some of Helidon’s features are listed below:
- Fast start-up time, low memory consumption and low disk space usage
- Ability to choose a “flavour” between the lightweight Helidon SE and the more intuitive Helidon MP
- Full MicroProfile support with Helidon MP: Eclipse MicroProfile is a specification which defines a set of standard APIs for developing microservices and Helidon MP fully implements these APIs
- Full support for GraalVM native image which allows you to compile your Java application ahead of time into a native standalone executable that can start faster and consume less memory
- A custom Helidon WebServer which is a virtual threads-based server built from the ground up by the Helidon team that allows nearly unlimited concurrent requests
- Observability and metrics with OpenTelemetry, Jaeger, Prometheus, etc.
- Helidon is a very modern microservice framework that is committed to using the newest Java features and makes no compromises about staying current with the latest JDK version
Possible Helidon disadvantages include:
- Because Helidon a fairly new framework, there aren’t as many adopters and the community isn’t as big as, for example, Spring Boot’s
- Major changes between versions: for example, version 4 removed the Reactive WebServer/Client that were based on Netty in favour of their own virtual threads-based Helidon WebServer and converted reactive API modules to blocking style APIs – this is a very big change that can potentially impact services already written with Helidon SE 3 (or earlier)
- Helidon is very keen on staying current with the latest Java and it heavily relies on new features like virtual threads: this is not necessarily a disadvantage (quite the opposite), but if you are reluctant to regularly upgrade your Java runtime, this might not be the framework for you
Oracle Helidon is a prime example of a project that leverages the latest Java advancements and applies them to their fullest potential. It is a framework that moves fast and quickly adapts to new developments in the Java world. Helidon is used by many internal Oracle projects, as well as external companies like Swedish telco Tele2.
Red Hat’s Quarkus is another recent open source project that was initially released in 2019. The Quarkus framework is designed around a container-first philosophy and its primary goal is to optimise applications for low memory usage and fast start-up time in order to make Java a leading platform in Kubernetes and serverless environments. Quarkus developers have seen the shortcomings of traditional Java stacks where Java applications have a lot of dependencies, long start-up times and large memory requirements and have created this new framework to meet the needs of the Kubernetes/serverless world. This is done by specific application tailoring for the GraalVM and HotSpot JVMs, reduction in reflection usage and overall focus on doing as much as possible during build time instead of runtime.
Quarkus features include:
- Optimised for very fast start-up time and lower memory footprint, making it very suitable for serverless environments
- Out-of-the-box live coding capabilities in development mode: when developers make a change, code is instantly rebuilt and the results can immediately be checked
- Combining both the familiar imperative coding style and the non-blocking reactive style, giving developers a choice which model to leverage
- Full support for GraalVM native images which eliminates unreachable code within your application or any of its dependencies and pre-builds it into native machine binary, resulting in a smaller executable, much faster start-up time and lower memory usage
- Implements specification standards like Jakarta EE and MicroProfile
Quarkus disadvantages include:
- There is a learning curve for initially installing and setting up GraalVM for building native images
- Although there are quite a few big adopters, the Quarkus community is still significantly smaller than Spring Boot’s
- Because it’s a newer framework, it might be harder and more costly to gather a team of Quarkus developers in comparison to, for example, Spring Boot
Quarkus is a modern Java microservice framework that optimises applications for containers, enabling them to work efficiently and scale cost-effectively in serverless, cloud and Kubernetes environments. It boosts development productivity with its live coding feature and support for both imperative and reactive programming styles. Quarkus adopters include well-known companies like Lufthansa Technik, Banco do Brasil, Logicdrop and others.
Micronaut is another open source addition to the “new-age” lightweight microframeworks for Java. It was released in 2018 by the creators of the popular Grails framework, and, to quote the authors, “takes inspiration from lessons learnt over the years building real-world applications from monoliths to microservices using Spring, Spring Boot and Grails”. Micronaut provides well-known general features like dependency injection, AOP and annotation-based autoconfiguration, as well as specific capabilities for distributed environments like service discovery, HTTP routing and client-side load balancing. Micronaut prides itself on being a polyglot framework that is compatible with Java, Kotlin and Groovy, with Scala on the way. Like some of the above mentioned frameworks, Micronaut is also GraalVM-ready and offers fast start-up time and low memory consumption which are not tied to the size of your project’s codebase.
Some of Micronauts’s features are:
- Specifically designed to be suitable for serverless functions with fast start-up time and reduced memory footprint
- Dependency injection / inversion of control and aspect-oriented programming runtime that uses no reflection – dependencies are resolved at the time of compilation
- Faster and easier integration testing, allowing you to instantly spin up and run servers/clients in your tests
- Multi-language support including Java, Kotlin, Groovy and eventually, Scala
- APIs that are inspired by well-known frameworks like Spring and Grails with familiar annotations and behaviours, resulting in a smoother learning curve for developers
- Multiple features centred around cloud-based microservices like service discovery, distributed tracing, load balancing
A few Micronaut disadvantages:
- Similarly to Helidon and Quarkus, Micronaut’s developer community isn’t as large and mature as it is for long-standing projects like Spring Boot
- Because Micronaut utilises its own set of APIs inspired by Spring and Grails, it does not implement standards like MicroProfile
- Although Micronaut offers application health and monitoring endpoints out-of-the-box, functionalities may be limited as compared to solutions like Spring Actuator
Overall, Micronaut is a modern framework for building microservices with an emphasis on serverless applications. Its APIs are inspired and adjacent to Spring’s, but Micronaut aims to avoid Spring’s shortcomings by providing fast startup and reduced memory usage, minimal use of reflection and proxies, easy unit testing, etc. Micronaut has quickly gained a firm foothold in the microservice world and is used by giants like Disney, Samsung, Minecraft / Mojang Studios, Target, etc.
Some of Vert.x’s features are:
- Produces very lightweight and fast reactive microservices
- The Vert.x toolkit is largely unopinionated on how you structure your code, what build tools you want to use, how you package and deploy your project, which gives you flexibility to configure your microservices on a lower level
- Vert.x is highly modular, allowing you to only include toolkit components that you actually need which keeps your code and builds slick
- The toolkit ships with no “black magic”: “what you write is actually what you get to execute” (quote from the Vert.x official website)
- Microservice-specific features include service discovery, distributed configuration, circuit-breaker pattern implementation to mitigate failures, etc.
- Distributed tracing, monitoring, observability and metrics with the Vert.x Health Checks component, Zipkin, OpenTelemetry, Dropwizard metrics, etc.
Disadvantages of using Vert.x include:
- Because Vert.x is an unopinionated toolkit rather than a whole framework, developers might need to implement or manually configure specific functionalities that could be available to them out-of-the-box with frameworks like Spring Boot
- While Vert.x has been around for a long time and has a persistent community, it still isn’t as large as Spring Boot’s
- Possible steep learning curve for developers that come from a non-reactive programming background
Eclipse Vert.x is a very lightweight toolkit with “no magic” that allows you to write scalable reactive microservices. Thanks to its modularity, it literally gives you the building blocks to create an application (or even a framework) of your own. According to the official Vert.x website, companies that use Vert.x include Hulu, ING, Swiss Post, Zalando, etc.
Over the past decade, there has been a noticeable transition from traditional monolithic systems to microservices. Many companies have chosen to develop new or revamp existing projects using the microservice architecture approach. Having multiple loosely coupled microservices means that each one can be individually developed, deployed and scaled, thereby overcoming some of the limitations of traditional monoliths.
Java is a preferred language when it comes to building microservices and naturally, there are multiple frameworks that can be leveraged by developers to ease the microservice development process and boost productivity. In this tech note, we have looked at 5 of the most popular Java frameworks for building microservices:
- Spring Boot: a mature framework that has stood the test of time and includes everything you need. Great and proven choice if you want to quickly put together a team that will develop microservices that start small, but have potential to iterate and grow in the future
- Oracle Helidon: a newer cloud-native set of Java libraries for writing microservices. Ideal for you, if you want to use a cutting-edge framework that is very strict with staying up-to-date with Java and leverages brand new features like virtual threads
- Quarkus: a Kubernetes-native Java framework tailored for GraalVM and HotSpot. Great choice for applications in serverless environments that require very fast boot time and low memory footprint
- Micronaut: a modern JVM-based framework for building modular and easily testable microservices. Perfect if you come from a Spring Boot or Grails background and want to develop serverless applications / microservices that have low startup time and small memory usage
- Eclipse Vert.x: a toolkit for building reactive applications on the JVM. Use Vert.x if you want to be able to write fast reactive microservices in different languages without any “magic” that happens under the hood
These are just some of the many Java frameworks available. Although it seems like Spring Boot is the current favourite, one should always be aware of and get familiar with alternatives: this way, you can choose what technologies to use based on your requirements, not vice-versa. Hopefully this article has given you some new information or has inspired you to delve deeper and try out some different frameworks for building Java microservices!
By Yoana Ivanova, Consultant at Estafet
- Martin Fowler’s official website – “Microservices”: https://martinfowler.com/articles/microservices.html
- Spring.io – Microservices: https://spring.io/microservices
- Spring Projects: https://spring.io/projects
- Helidon Official Website: https://helidon.io/
- Helidon 4 Release: https://www.youtube.com/watch?v=u-kSM9G9Z0Y
- Helidon – Microservices on Modern Java: https://www.youtube.com/watch?v=diUvR6gqHVY
- Quarkus Official Website: https://quarkus.io/
- Introduction to Quarkus – “Supersonic Subatomic Java”: https://www.youtube.com/watch?v=DYcEQs-9sb0
- Micronaut Framework Official Website: https://micronaut.io/
- Eclipse Vert.x Official Website: https://vertx.io/
- “Vert.x in Action” book by Julien Ponge