Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Microservices with Micronaut - practical approach

Microservices with Micronaut - practical approach

1. Micronaut - what’s is it?
2. Reflection based vs compile time based approach to DI/AOP
3. Simplified Insurance Sales System - intro
4. Implementation examples

Robert Witkowski

June 18, 2019
Tweet

More Decks by Robert Witkowski

Other Decks in Programming

Transcript

  1. Agenda 1. Micronaut - what’s is it? 2. Reflection based

    vs compile time based approach to DI/AOP 3. Simplified Insurance Sales System - intro 4. Implementation examples 5. DEMO - Micronaut & GraalVM 6. DEMO - performance tests (startup, memory)
  2. Micronaut features • lightweight and reactive • supports Java, Kotlin,

    Groovy • supports Maven/Gradle as build tools • built by the people that made Grails (over 10 years exp) • designed with microservices and cloud computing in mind with a lot of cloud-native features like: – service discovery – distributed tracing – asynchronous communication – retriable HTTP clients – circuit breakers – scalability and load balancing – external configuration
  3. https://www.thoughtworks.com/radar/languages-and-frameworks ThoughtWorks Technology Radar The Assess ring are things to

    look at closely, but not necessarily trial yet - unless you think they would be a particularly good fit for you. Typically, blips in the Assess ring are things that we think are interesting and worth keeping an eye on.
  4. • No common reflection cache in Java, each library/framework produces

    a unique reflection cache. This makes it extremely difficult to optimize memory consumption. • Reflective calls are much more difficult for the JIT to optimize. • Traditional AOP is the heavy reliance on runtime proxy creation which slows app performance, makes debugging harder and increases memory consumption. https://stackoverflow.com/questions/435553/java-reflection-performance Reflection based approach to DI/AOP
  5. Reflection is powerful, but should not be used indiscriminately. If

    it is possible to perform an operation without using reflection, then it is preferable to avoid using it. Because reflection involves types that are dynamically resolved, certain JVM optimizations can not be performed. Consequently, reflective operations have slower performance than their non-reflective counterparts, and should be avoided in sections of code which are called frequently in performance-sensitive applications. https://docs.oracle.com/javase/tutorial/reflect/index.html Trail: Reflection API
  6. • Processes classes at compile time and produces all metadata

    at compile time. • Doesn’t need to scan all your classes, methods, properties to “understand” your app. • Uses Ahead of Time (AOT) compilation via annotation processors or AST transforms for Groovy. Micronaut compile-time approach to DI/AOP
  7. • improves startup performance • reduces memory consumption • reducing

    proxies and stack trace sizes • improving debugging Micronaut compile-time approach to DI/AOP
  8. Accessing Relational Database with Micronaut Data Micronaut Data is a

    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 • no query translation • no reflection or runtime proxy • type safety https://micronaut-projects.github.io/micronaut-data/latest/guide/
  9. What’s else? • Micronaut AWS • Micronaut gRPC • Micronaut

    Flyway • Micronaut Liquibase • Micronaut GraphQL • Micronaut ElasticSearch • Micronaut Redis • Micronaut Neo4j • ....
  10. Deployment • docker-compose – localhost only – consul-based service-discovery •

    kubernetes – local & cloud – dns-based service-discovery
  11. GraalVM GraalVM is a universal virtual machine for running applications

    written in JavaScript, Python, Ruby, R, JVM-based languages like Java, Scala, Kotlin, Clojure, and LLVM-based languages such as C and C++.