Introduction to Micronaut - Object Computing
Transcript of Introduction to Micronaut - Object Computing
![Page 1: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/1.jpg)
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved. No part of these notes may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior, written permission of Object Computing, Inc. (OCI)
WEBINAR
Introduction to Micronaut
Ultra-Lightweight Microservices for the JVM
Graeme Rocher | November 14, 2018
![Page 2: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/2.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
• Creator: Grails (grails.org)
• Creator: Micronaut (micronaut.io)
• Author: The Definitive Guide to Grails (Apress, 2009)
• Senior Software Engineer at Object Computing, Inc. (objectcomputing.com)
• 2018 Oracle Groundbreaker Award Winner
ABOUT THE PRESENTER: GRAEME ROCHER
![Page 3: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/3.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
• How We Got Here
• Microservice Challenges
• Microservice Framework Landscape
• Micronaut Demos
AGENDA
![Page 4: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/4.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
HOW WE GOT HERE
![Page 5: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/5.jpg)
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
THEN AND NOW
● Since 2008, a lot has changed
● 10 years is a long time in
technology
● Everybody was building monoliths
● No Angular, no React, no Docker,
no microservices
![Page 6: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/6.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
● Let’s try to adapt existing
legacy technologies to
microservices
● Technologies like Spring,
Jakarta EE, and others
were never optimized for
low-memory footprint
microservices
SO WE TRY TO ADAPT
![Page 7: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/7.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
MICROSERVICE CHALLENGES
![Page 8: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/8.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
Shall we:
1. Try to convince people that
something never designed for
microservices is still okay?
or . . .
2. Go back to the drawing board?
WHAT TO DO, WHAT TO DO?
![Page 9: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/9.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved.objectcomputing.com
THE GOAL
Create a new framework designed from the
ground up for microservices and serverless
computing
• Blazing-fast startup time
• Low-memory footprint
• As small as possible JAR sizes
• Zero dependency
• 12 Factor (https://12factor.net)
![Page 10: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/10.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
MICROSERVICE FRAMEWORK LANDSCAPE
![Page 11: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/11.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved.objectcomputing.com
To meet this goal, we performed an
analysis of Spring and Grails and
the challenges of using them to
develop microservice applications.
THE ANALYSIS
![Page 12: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/12.jpg)
WHAT SPRING AND JAKARTA EE DO
Spring and Jakarta EE are amazing technical achievements. They
do all of the following . . . but they do them at runtime.
● Read the byte code of every bean they find
● Synthesize new annotations for each annotation on each
bean method, constructor, field, etc., to support annotation
metadata
● Build reflective metadata for each bean for every method,
constructor, field, etc.
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
![Page 13: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/13.jpg)
SO WHAT’S THE PROBLEM?
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
![Page 14: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/14.jpg)
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
![Page 15: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/15.jpg)
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
● Frameworks based on reflection and
annotations become fat.
● But we love the programming model and
productivity, so we live with it.
● So … how can we be more efficient?
THE MICRO REALITY
![Page 16: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/16.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
Imagine if Kubernetes or Docker had been written in
Spring or Jakarta EE instead of Go …
![Page 17: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/17.jpg)
ALREADY SOLVED BY AHEAD-OF-TIME (AOT) COMPILATION
The Android community already solved the problem
● AOT compilation used extensively
● Google Dagger 2.x
• Compile-time dependency injector
• Reflection free
• Limited in scope to just DI
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
![Page 18: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/18.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved.objectcomputing.com
● Designed from the ground up with
microservices in mind
● Ultra-lightweight and reactive, based
on Netty
● Uses AOT compilation
● HTTP client and server
● Support for Java, Kotlin, and Groovy
INTRODUCING MICRONAUT
![Page 19: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/19.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
MICRONAUT DEMOS
![Page 20: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/20.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
Hello Micronaut
![Page 21: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/21.jpg)
HELLO MICRONAUT
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
@Controller
class HelloController {
@Get("/hello/{name}")
String hello(String name) { return "Hello " + name; }
}
@Client("/") // Client Generated at Compile Time
interface HelloClient {
@Get("/hello/{name}")
String hello(String name);
}
![Page 22: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/22.jpg)
HOW SMALL?
● Smallest Micronaut Hello World JAR is 10MB when written in
Java and 12MB in Groovy
● Can be run with as little as 10MB max heap with Kotlin and Java
(22 for Groovy)
● Startup time is around a second for Kotlin and Java (a little more
for Groovy)
● All dependency injection, AOP, and proxy generation happens at
compile time
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
![Page 23: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/23.jpg)
WHAT MICRONAUT COMPUTES COMPILE TIME
● All dependency and configuration injection
● Annotation metadata (meta annotations)
● AOP proxies
● Essentially all framework infrastructure (i.e., what Spring/CDI do
at runtime)
Essentially, Micronaut is an AOT framework
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
![Page 24: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/24.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved.objectcomputing.com
● New little HTTP frameworks appearing
all the time
● If all we had achieved was another
HTTP server, Micronaut wouldn't be
very interesting
● What else does it do?
NOT ANOTHER SERVER!?
![Page 25: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/25.jpg)
NATIVELY CLOUD NATIVE
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
● Service Discovery – Consul, Eureka, Route 53, and Kubernetes
● Configuration Sharing – Consul supported and Amazon
ParameterStore
● Client-Side Load Balancing – Integrated or Netflix-Ribbon
supported
● Support for serverless computing; AWS Lambda, OpenFaas, Fn
supported; Azure coming
![Page 26: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/26.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
Micronaut Pet Store
![Page 27: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/27.jpg)
SERVERLESS COMPUTING
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
● Write functions and run them locally or as regular server applications
● Deploy functions to AWS Lambda; after warmup, functions execute in milliseconds
@Field @Inject Twitter twitter
@CompileStatic
URL updateStatus(Message status){
Status s = twitter.updateStatus(status.text)
String url = "https://twitter.com/$s.user.screenName/status/${s.id}"
return new URL(url)
}
![Page 28: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/28.jpg)
GraalVM
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
● New Polyglot VM from Oracle
● Runs JS, Java, Ruby, R, etc.
● Ability to turn Java code native
● http://www.graalvm.org
![Page 29: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/29.jpg)
GraalVM NATIVE
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
Works well when:
● Little or no runtime reflection is used
● There's limited or no dynamic classloading
● You plan ahead
● Third-party libraries are used selectively
![Page 30: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/30.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved. objectcomputing.com
Micronaut +
![Page 31: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/31.jpg)
MICRONAUT + GraalVM
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
● Like Graal itself at the experimental phase
● Micronaut AOT compilation and reflection-free model
makes it easier
● A lot of Micronaut already working:
● HTTP server, client, and serverless
● Service discovery
● DI and AOP
![Page 32: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/32.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved.objectcomputing.com
● Compile-time DI and AOP
● HTTP client and server
● Service discovery
● Distributed tracing
● Serverless functions
● Data access: SQL, MongoDB, Redis,
Cassandra, etc.
MICRONAUT 1.0 OUT NOW
![Page 33: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/33.jpg)
MICRONAUT 1.0 ON SDKman!
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
The Micronaut CLI is now available via SDKman!
$ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
$ sdk install micronaut
$ mn create-app hello-world
![Page 34: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/34.jpg)
MICRONAUT RESOURCES
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
● Gitter Community: https://gitter.im/micronautfw
● User Guide: http://micronaut.io/documentation.html
● Micronaut Guides: http://guides.micronaut.io
● FAQ: http://micronaut.io/faq.html
● GitHub: https://github.com/micronaut-projects/micronautcore
● Examples: https://github.com/micronaut-projects/ micronaut-
examples
![Page 35: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/35.jpg)
UPCOMING MICRONAUT EVENTS
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
● Micronaut Deep Dive
● 3-day online workshop
● https://objectcomputing.com/training/catalog/micronaut-training/micronaut-
deep-dive
● Devnexus 2GM 2019
● 2GM (Groovy, Grails and Micronaut) to be featured at Devnexus 2019
● https://devnexus.com/
● Micronaut Summit 2019
● Micronaut-focused conference
● https://micronautsummit.com/
![Page 36: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/36.jpg)
SUMMARY
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
● Micronaut aims to provide the same "WOW" factor for
microservices that Grails did for monoliths
● Built by the people that created Grails, leveraging over 10
years experience in framework development
● Uses AOT compilation to support low memory footprint
● Micronaut 1.0 is available now
![Page 37: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/37.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved.
Q & A
![Page 38: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/38.jpg)
© 2018, Object Computing, Inc. (OCI). All rights reserved.
LEARN MORE ABOUT OCI EVENTS & TRAINING
Events:
● objectcomputing.com/events
Training:
● objectcomputing.com/training
● grailstraining.com
● micronauttraining.com
Or email [email protected] to schedule a custom training program for your team online,
on site, or in our state-of-the-art, Midwest training lab.
![Page 39: Introduction to Micronaut - Object Computing](https://reader033.fdocuments.in/reader033/viewer/2022050613/62749ee8698f93780139ed13/html5/thumbnails/39.jpg)
objectcomputing.com© 2018, Object Computing, Inc. (OCI). All rights reserved.
CONNECT WITH US
1+ (314) 579-0066
@objectcomputing
objectcomputing.com