Micronaut 3. 2 Released for More Performant Microservices
Written by Nikos Vaggalis   
Wednesday, 22 December 2021

Micronaut, the JVM-based polyglot framework for building microservices applications in Java, Kotlin and Groovy has reached version 3. 2. Before we look at what's new, let's first take a look at what the framework does differently.

Yes, there's other options of going Microservices than the combination of Spring Boot and Spring Cloud. Helidon, Dropwizard, Microprofile and Quarkus are some of those options. And there's Micronaut. 

Spring of course is a monumental piece of technology;a versatile framework that does a lot under the covers to boost developer productivity. That magic comes with a drawback however. The magic Spring pulls is happening at runtime, analyzing your code and the annotations, injecting beans, etc thus using a lot of runtime loading as well as Reflection under the hood. And with bloated runtime comes an upshot on memory usage and of course startup time. The usual recipe of those stacks against performance hampering is caching but that comes with even more memory load.

Micronaut which gives you the same productivity boon as Spring, since the notion and code written against it are very similar, which of course make the transition a straightforward endeavor by providing the same dependency injection, inversion of control (IOC), and Aspect-Oriented Programming (AOP) but with massive memory and startup time savings at the same time.

The underlying technology was already there, on Android. The pointers of course is on the Ahead Of Time Compilation, a technique which determines what the application is going to need at compile time in order to avoid reflection completely thus keeping memory requirements down and performance up by doing more things at compile time than at runtime.

Now it was time for others to pick the concept up and adapt it to the requirement of the Cloud, which is exactly what Micronaut did. Micronaut is a generic application framework, so it can be used to build not just microservice applications but also other kinds like event-driven ones, that generates additional code at compile-time to implement things like dependency injection and avoiding runtime proxies. The trade-off is slower build time vs. faster runtime.

To take it a step further Micronaut plays well along GraalVM, the runtime that compiles Java bytecode into native self-contained executables, under which it can create native images which can reduce the start up time to miliseconds up to 100x faster than when running on the JVM. Of course by giving up platform portability since the image made is machine specific.

A glimpse at its advantages can be found in the Micronaut Data project description, the database access toolkit that uses Ahead of Time (AoT) compilation to pre-compute queries for repository interfaces that are then executed by a thin, lightweight runtime layer

  • No runtime model - Spring Data maintains a runtime meta-model that uses reflection to model relationships between entities. This model consumes significant memory and memory requirements grow as your application size grows. The problem is worse when combined with Hibernate which maintains its own meta-model as you end up with duplicate meta-models.
  • No query translation - Spring Data uses regular expressions and pattern matching in combination with runtime generated proxies to translate a method definition on a Java interface into a query at runtime. No such runtime translation exists in Micronaut Data and this work is carried out by the Micronaut compiler at compilation time.
  • No Reflection or Runtime Proxies - Micronaut Data uses no reflection or runtime proxies, resulting in better performance, smaller stack traces and reduced memory consumption due to a complete lack of reflection caches (Note that the backing implementation, for example Hibernate, may use reflection).
  • Type Safety - Micronaut Data will actively check at compile time that a repository method can be implemented and fail compilation if it cannot.

The major release v3 of the framework was in August and in November 23 there was another inportant update to v3. 2. Let's take a quick look at what 3. 2 included:

  • Updated to support the latest GraalVM 21. 3. 0 release
  • The official GraalVM Maven plugin has new coordinates
  • A new major version of the Gradle plugin
  • Updated to support Kotlin 1. 6. 0.
  • Websocket Improvements

Many modules upgrades:

  • Micronaut Data
  • Micronaut Security
  • Micronaut Openapi
  • Reactive Library Modules
  • Micronaut Kubernetes
  • Schema Migration Modules
  • Micronaut Elasticsearch

Full changelog on the project's Github repo.

Of course, Micronaut comes with reactive extensions and runtime support for the following backends:

JPA (Hibernate)

SQL (JDBC, R2DBC)

Check this example for Hibernate..

mnautsq

More Information

Micronaut Github

Micronaut.io 

Related Articles

Compile Spring Applications To Native Images With Spring Native

GraalVM 21.3 Released

Hibernate goes Reactive - What Does That Mean? 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Developer Sabotages Own Code
13/01/2022

The developer of two popular JavaScript libraries has sabotaged them, apparently as a protest for not getting financial recompense from corporates for his work. GitHub temporarily suspended his accoun [ ... ]



Coursera Plus For A Year's Worth Of Study
07/01/2022

If your New Year's resolutions include gaining new skills or obtaining credentials to further your career, having a $100 discount on an annual Coursera Plus subscription sounds like a really good deal [ ... ]


More News

square

 



 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Wednesday, 22 December 2021 )