The document discusses Micronaut, a new Java framework that aims to address challenges of serverless and microservices environments. It focuses on ahead-of-time (AOT) compilation using GraalVM to improve startup times and reduce memory usage compared to frameworks like Spring that rely heavily on reflection and dynamic classloading. The document demonstrates how Micronaut can help modernize Java applications for microservices through AOT compilation and provides resources for learning more.
4. @aalmiray | andresalmiray.com
Serverless Challenges
• For Java, the serverless/microservices world is different
than the big application server world.
• Existing tools not optimised for cold starts, low memory
usage, fast startup, etc.
• Alternatives as Go, Node fare better in these regards.
5. @aalmiray | andresalmiray.com
Containers everywhere!
• Containers have become the deployment unit.
• Special care needed for memory management when
running Java on containers.
• Memory usage requires optimizations.
6. @aalmiray | andresalmiray.com
Spring?
• Spring Boot lowered the bar to get started with code.
• A lot of magic is found under the covers, and
unfortunately at runtime too
• Classpath scanning
• Synthethizes new annotations
• Heavy use of reflection
7.
8.
9. @aalmiray | andresalmiray.com
Java’s ailments for
framework authors
• Limited Annotation API
• Type Erasure
• Slow Reflection
• Reflective Data Caches
• Classpath Scanning
• Slow Dynamic Class Loading
10. @aalmiray | andresalmiray.com
Why Java then?
• Mature, robust ecosystem
• Excellent IDE support
• Code maintenance and refactoring
• Build system maturity
• Diverse deployments (mobile, server, client, IoT)
• Diverse languages (Java, Groovy, Kotlin, Scala, …)
• Developers! Developers! Developers!
11.
12. @aalmiray | andresalmiray.com
• A Microservices and Serverless focused framework.
• Also a d complete application framework for any type of
application: cli, webapp, android, swing.
• Brings all the features you know and love:
• Dependency Injection, AOP, Configuration
Management, Bean Introspection, and more…
14. @aalmiray | andresalmiray.com
• A new universal Virtual Machine from Oracle
• JIT compiler written in Java
• Features a Native Image tool
• Converts Java -> native code using AOT
• Even lower startup and memory consumption!
17. @aalmiray | andresalmiray.com
Static Compilation of Java
Applications at Alibaba at Scale
• https://medium.com/graalvm/static-compilation-of-java-
applications-at-alibaba-at-scale-2944163c92e
• Switching to Graal led to
• Faster startup times
• Improved GC performance
18. @aalmiray | andresalmiray.com
Spring -> Micronaut
• https://micronaut-projects.github.io/micronaut-spring/
latest/guide/
• Spring annotations can be used with Micronaut’s Compile
time support.
• Enables smooth migration from Spring into Micronaut.
19. @aalmiray | andresalmiray.com
Summary
• Micronaut and GraalVM are leading the AOT revolution
• Server side Java is adapting to the server less world
• AOT sacrifices compilation speed to gain more at
deployment/production
• Native image provide additional benefits