• Blog
  • Info Support
  • Career
  • Training
  • International Group
  • Info Support
  • Blog
  • Career
  • Training
  • International Group
  • Search
logo InfoSupport
  • Latest blogs
  • Popular blogs
  • Experts
      • All
      • Bloggers
      • Speakers
  • Meet us
  • About us
    • nl
    • en
    • .NET
    • 3D printing
    • Advanced Analytics
    • Agile
    • Akka
    • Alexa
    • Algorithms
    • Api's
    • Architectuur
    • Artificial Intelligence
    • ATDD
    • Augmented Reality
    • AWS
    • Azure
    • Big Data
    • Blockchain
    • Business Intelligence
    • Chatbots
    • Cloud
    • Code Combat
    • Cognitive Services
    • Communicatie
    • Containers
    • Continuous Delivery
    • CQRS
    • Cyber Security
    • Dapr
    • Data
    • Data & Analystics
    • Data Science
    • Data Warehousing
    • Databricks
    • DataOps
    • Developers life
    • DevOps
    • Digital Days
    • Digital Twin
    • Docker
    • eHealth
    • Enterprise Architecture
    • Event Sourcing
    • Hacking
    • Infrastructure & Hosting
    • Innovatie
    • Integration
    • Internet of Things
    • Java
    • Machine Learning
    • Microservices
    • Microsoft
    • Microsoft Bot Framework
    • Microsoft Data Platform
    • Mobile Development
    • Mutation Testing
    • Open source
    • Pepper
    • Power BI
    • Privacy & Ethiek
    • Python
    • Quality Assistance & Test
    • Quality Assurance & Test
    • Requirements Management
    • Scala
    • Scratch
    • Security
    • SharePoint
    • Software Architecture
    • Software development
    • Software Factory
    • SQL Server
    • SSL
    • Start-up
    • Startup thinking
    • Stryker
    • Test Quality
    • Testing
    • TLS
    • TypeScript
    • Various
    • Web Development
    • Web-scale IT
    • Xamarin
    • All
    • Bloggers
    • Speakers
Home » Micronaut: a new Spring-like framework focussed on minimal memory consumption
  • Micronaut: a new Spring-like framework focussed on minimal memory consumption

    • By Jack Sierkstra
    • Docker 4 years ago
    • Docker 0 comments
    • Docker Docker
    Micronaut: a new Spring-like framework focussed on minimal memory consumption

    In the week of 22 October 2018, me and two colleagues visited Oracle CodeOne (previously known as JavaOne) in San Francisco. One of the talks was from Graeme Rocher, the creator of the Grails framework. His talk was about Micronaut. The new kid on the block on JVM-based frameworks.

    Increasing memory consumption

    Nowadays, there are a lot of organisations who choose Spring Boot as their preferred framework when developing new microservices. Mainly because Spring Boot is really easy to setup, there is a vibrant community and a lot of guides to get you up and running. A problem with Spring in general, is that the memory consumption grows quite steadily once you begin adding functionality to your microservice. When you have a complete landscape consisting of numerous Spring-based  microservices, the operational costs can increase and the ease of development becomes less.

    Runtime vs Compile-time

    That is where Micronaut comes into play. It was created to eliminate aforementioned problems while still offering the ease of development and setting everything up. You probably wonder how they achieve that? Mainly it comes down to how they work internally. Spring does dependency injection based on reflection. It also saves and caches a lot of information during runtime which clogs up the memory once you start adding functionality.

    Micronaut does this different. It does dependency injection based on annotation processors which precompile the metadata needed. Because everything needed for dependency injection is done at compile time, it doesn’t have to do this at runtime and that can save a lot of memory in the long run.

    An example

    In order to show you the difference between both frameworks, I constructed a little example. The examples are ran on a MacBook Pro (15-inch, 2017).

    At first I created a simple “/hello-world” endpoint in both the Micronaut and Spring application. Code for these examples can be found at https://github.com/jacksierkstra/hello-world-micronaut and https://github.com/jacksierkstra/hello-world-spring.

    In order to build a runnable docker container, you’ll just have to clone the repository and run “docker build -t micronaut:latest .” In the cloned Micronaut repository. If you want to build the Spring Docker container, you’ll have to clone that repository and run “docker build -t spring:latest .” In the cloned Spring repository.

    In order to run these containers side by side, you can issue these simple commands.

    • docker run -d -p 8080:8080 spring:latest
    • docker run -d -p 8081:8080 micronaut:latest

    Now you have the two examples running and you can verify that by running “docker ps”. The output should be similar to the image below.

    You can verify that the containers are running correctly by doing a http request to them. In the images below you can see that they both contain a “/hello-world” endpoint with a simple JSON response.

    Spring container:

    Micronaut container:

    And if you check the output of the “docker stats” command, you’ll see that the Micronaut container consumes about half of the memory than the Spring container does.

    Conclusion

    Above example is very simple, but it shows that Micronaut is much more memory efficient. This is purely because it was designed to do this. If you add up a couple of Spring containers, you’ll notice that you are very quickly battling against your machine limits.

    Share this

Jack Sierkstra

View profile

Related blogs

  • How-to clean up your Docker Desktop and reclaim that di…

    How-to clean up your Docker Desktop and reclaim that di… Willem Meints - 6 months ago

  • Develop Kubernetes solutions on your own machine with S…

    Develop Kubernetes solutions on your own machine with S… Willem Meints - 2 years ago

  • ‘docker run’ throws “exec user process” errors

    ‘docker run’ throws “exec user process” errors Michaël Hompus - 5 years ago

Data Discovery Channel

  • Explainable AI - Break open the blackbox

  • Toekomstvaste microservice data architecturen

  • Modern Data Platform

Nieuwsbrief

* verplichte velden

Contact

  • Head office NL
  • Kruisboog 42
  • 3905 TG Veenendaal
  • T +31 318 552020
  • Call
  • Mail
  • Directions
  • Head office BE
  • Generaal De Wittelaan 17
  • bus 30 2800 Mechelen
  • T +32 15 286370
  • Call
  • Mail
  • Directions

Follow us

  • Twitter
  • Facebook
  • Linkedin
  • Youtube

Newsletter

Sign in

Extra

  • Media Library
  • Disclaimer
  • Algemene voorwaarden
  • ISHBS Webmail
  • Extranet
Beheer cookie toestemming
Deze website maakt gebruik van Functionele en Analytische cookies voor website optimalisatie en statistieken.
Functioneel Always active
De technische opslag of toegang is strikt noodzakelijk voor het legitieme doel het gebruik mogelijk te maken van een specifieke dienst waarom de abonnee of gebruiker uitdrukkelijk heeft gevraagd, of met als enig doel de uitvoering van de transmissie van een communicatie over een elektronisch communicatienetwerk.
Voorkeuren
De technische opslag of toegang is noodzakelijk voor het legitieme doel voorkeuren op te slaan die niet door de abonnee of gebruiker zijn aangevraagd.
Statistieken
De technische opslag of toegang die uitsluitend voor statistische doeleinden wordt gebruikt. De technische opslag of toegang die uitsluitend wordt gebruikt voor anonieme statistische doeleinden. Zonder dagvaarding, vrijwillige naleving door uw Internet Service Provider, of aanvullende gegevens van een derde partij, kan informatie die alleen voor dit doel wordt opgeslagen of opgehaald gewoonlijk niet worden gebruikt om je te identificeren.
Marketing
De technische opslag of toegang is nodig om gebruikersprofielen op te stellen voor het verzenden van reclame, of om de gebruiker op een website of over verschillende websites te volgen voor soortgelijke marketingdoeleinden.
Manage options Manage services Manage vendors Read more about these purposes
Voorkeuren
{title} {title} {title}