Skip to content

Latest commit

 

History

History
477 lines (299 loc) · 9.97 KB

November-Webinar-2018.md

File metadata and controls

477 lines (299 loc) · 9.97 KB

theme: OCI White slidenumbers: false [.hide-footer]

original

[FIT] Introduction to Micronaut

Ultra-Lightweight Microservices for the JVM

-- by Graeme Rocher


original

[.text: #000000, text-scale(0.8), alignment(left)]

About Me - Graeme Rocher


original

[.text: #000000, text-scale(0.8), alignment(left)]

Agenda

  • How we got here
  • Microservice Challenges
  • Microservice Framework Lanscape
  • Micronaut Demos

original

right,50%

[.text: #000000, text-scale(0.8), alignment(left)]

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

So We Try to Adapt

original

[.text: #000000, text-scale(0.8), alignment(left)]

right

  • Let's try adapt existing legacy technologies for Microservices
  • Technologies like Spring, Jakarta EE etc were never optimized for low memory footprint Microservices

What to do,

What to do?

original

[.text: #000000, text-scale(0.8), alignment(left)]

Shall we:

  1. Try and convince people that something never designed for Microservices is still ok?
  2. Go back to the drawing board

left


original

[.text: #000000, text-scale(0.8), alignment(left)]

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

original

[.text: #000000, text-scale(0.8), alignment(left)]

The Analysis

To meet this goal we performed an analysis of Spring and Grails and the challenges to using them to develop Microservice applications

right


What Spring and Jakarta EE Do

[.text: #000000, text-scale(0.8), alignment(left)]

original

Spring is an amazing technical achievement and does so many things, but does them at Runtime.


So What's the Problem?

original

inline


original

inline 98%


[.text: #000000, text-scale(0.8), alignment(left)]

The Micro Reality

original

right

  • Frameworks based on reflection and annotations become fat
  • But we love the programming model and productivity so we live with it
  • So ... why should we be more efficient?

original

Imagine if Kubernetes or Docker had been written in Spring or Jakarta EE instead of Go?


original

[.text: #000000, text-scale(0.8), alignment(left)]

Already Solved by

Ahead of Time (AOT) Compilation

  • The Android Community already solved the problem
  • Ahead of Time Compilation used extensively
  • Google Dagger 2.x
    • Compile Time Dependency Injector
    • Reflection Free
    • Limited in Scope to just DI

original

[.text: #000000, text-scale(0.8), alignment(left)]

Introducing Micronaut

  • Designed from the ground up with Microservices in mind
  • Ultra-light weight and Reactive - Based on Netty
  • Uses Ahead of Time Compilation
  • HTTP Client & Server
  • Support for Java, Kotlin and Groovy

original

DEMO

  • Hello Micronaut

Hello Micronaut

original

[.hide-footer]

@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);
}

original

[.text: #000000, text-scale(0.8), alignment(left)]

How Small?

  • Smallest Micronaut Hello World JAR is 10MB when written Java or 12MB in Groovy
  • Can be run with as little as 10mb Max Heap with Kotlin or Java (22mb for Groovy)
  • Startup time around a second for Kotlin or Java (a little more for Groovy)
  • All Dependency Injection, AOP and Proxy generation happens at compile time

original

[.text: #000000, text-scale(0.8), alignment(left)]

What Micronaut Computes

Compile Time

  • All Dependency & Configuration Injection
  • Annotation Metadata (Meta annotations)
  • AOP Proxies
  • Essentially all framework infrastructure
  • ie. What Spring/CDI do at runtime
  • Essentially, Micronaut is a AOT framework

original

right

[.text: #000000, text-scale(0.8), alignment(left)]

Not Another Framework!?

  • 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?

[.text: #000000, text-scale(0.8), alignment(left)]

Natively Cloud Native

original

[.hide-footer]

  • 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

original

DEMO

  • Micronaut Pet Store

original

[.text: #000000, text-scale(0.8), alignment(left)]

Serverless Computing

  • Write Functions and Run them locally or as regular server applications
  • Deploy Functions to AWS Lambda - after warm-up 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)
}

original

right,99%

[.text: #000000, text-scale(0.8), alignment(left)]

GraalVM


[.text: #000000, text-scale(0.8), alignment(left)]

original

right,99%

GraalVM Native

  • Works well when:
    • Little or no runtime reflection is used
    • Limited or no dynamic classloading
    • You plan ahead
    • You use third party libraries selectively

original

right,99%

DEMO

  • Micronaut + GraalVM

[.text: #000000, text-scale(0.8), alignment(left)]

original

right,99%

Micronaut + GraalVM

  • Like Graal itself at the Experimental Phase
  • Mirconaut AOT compilation and refection free model makes it easier
  • A lot of Micronaut already working:
    • HTTP Server, Client & Serverless
    • Service Discovery
    • DI and AOP

original

[.text: #000000, text-scale(0.8), alignment(left)]

Micronaut 1.0 Out Now

  • Compile Time DI & AOP
  • HTTP Client & Server
  • Service Discovery
  • Distributed Tracing
  • Serverless Functions
  • Data Access: SQL, MongoDB, Redis, Cassandra etc.

original

Micronaut 1.0 on SDKman!

  • The Micronaut CLI 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

original

[.text: #000000, text-scale(0.8), alignment(left)]

Micronaut Resources


[.text: #000000, text-scale(0.8), alignment(left)]

original

Micronaut Events

right


[.text: #000000, text-scale(0.8), alignment(left)]

original

Summary

  • Micronaut aims to provide the same wow factor for Microservices that Grails did for Monoliths
  • Built by the people that made Grails, leveraging over 10 years experience in framework development
  • Uses Ahead of Time Compilation to support low-memory footprint
  • Micronaut 1.0 is available now

original

[.hide-footer]

[FIT] Q & A