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

Unleash the power of your applications with Mic...

Unleash the power of your applications with Micronaut and GraalVM

In this talk, Micronaut committer Álvaro Sánchez-Mariscal, will demonstrate how you can quickly build optimised Microservices with Micronaut & GraalVM Native Image. Attendees will learn how the combination of GraalVM Native Image and Micronaut can lead to efficient, highly performant, and optimised applications that can be perfectly deployed to environments like Kubernetes or serverless platforms.

There will be a live coding demo of an application using Micronaut Data and GraalVM.

Álvaro Sánchez-Mariscal

February 21, 2024
Tweet

More Decks by Álvaro Sánchez-Mariscal

Other Decks in Programming

Transcript

  1. Unleash the power of your applications with Micronaut® and GraalVM

    Álvaro Sánchez-Mariscal Principal Member of Technical Staff Oracle @alvaro_sanchez
  2. Álvaro Sánchez-Mariscal Principal Member of Technical Staff, Oracle • Coming

    from Madrid • Developer since 2001 (Java stack) • Micronaut core developer since its inception (2017). • Author: Maven Plugin, Object Storage, Kubernetes, Cache, Control Panel. • Others: Core, Gradle, AWS, GCP, Azure, Security, Test, etc. • Currently at Oracle Labs: • Micronaut and Graal Development Kit for Micronaut (GDK). • GraalVM Native Build Tools. • Speaker at conferences: Devoxx, GeeCON, JavaLand, JavaZone, jPrime, Codemotion, Commit Conf, etc. @alvaro_sanchez
  3. Copyright © 2024, Oracle and/or its affiliates. Micronaut® is a

    registered trademark of Object Computing, Inc. Use is for referential purposes and does not imply any endorsement or affiliation with any third-party product. 4
  4. Introduction to Micronaut Copyright © 2024, Oracle and/or its affiliates

    5 Micronaut is a complete solution for any type of application: microservices, message-driven producers or consumers, command-line apps, serverless functions, etc. All application types Micronaut leverages Java annotation processors and other optimisations to compute the framework infrastructure at compile-time, drastically reducing startup time and memory consumption. Highly optimised Modern, open-source Java Framework Micronaut has been designed from scratch in 2017, focused on modern architectures like microservices and serverless, and with the cloud in mind.
  5. Micronaut computes at build time: • All dependency and configuration

    injection. • Annotation metadata (meta annotations) • AOP proxies. • Bean introspections. • All other framework infrastructure. At runtime: • No reflection. • No proxy generation. • No dynamic classloading. • No classpath scanning. AOT: Ahead Of Time Copyright © 2024, Oracle and/or its affiliates 6 Source code @Singleton class MySvc {} Bytecode class $MySvc$Definition {} class $MySvc$Definition$Reference {} Source code @Builder record Person() {} Source code @Generated class PersonBuilder() {} compilation compilation
  6. 7 Any language, build tool, test framework, reactive library, cloud,

    … Copyright © 2024, Oracle and/or its affiliates
  7. Micronaut features: HTTP Client 9 Copyright © 2024, Oracle and/or

    its affiliates Implemented at compile time
  8. Micronaut features: message-driven applications Kafka • Producers. • Consumers. •

    Kafka Streams. RabbitMQ • Producers. • Consumers. • RPC. MQTT • Publishers. • Subscribers. NATS • Producers. • Consumers. Copyright © 2024, Oracle and/or its affiliates 10
  9. Micronaut features: data access 12 Copyright © 2024, Oracle and/or

    its affiliates Interface implemented at compile time Query generated from the method name, compile-time validated Can have custom queries, inserts, etc
  10. Micronaut features: security 1. Authentication providers. • Bult-in support for

    LDAP and OAuth 2.0 password grant flow. 2. Security rules. • Configuration or annotation-based. 3. Authorization strategies. • Basic auth, session, JWT (JWKS, JWS), X.509. 4. OAuth 2.0. • Authorization code, client credentials and password grants. • OpenID Connect. • Ease of integration with providers such as Okta, Auth0, AWS Cognito, Keycloak and more. 13 Copyright © 2024, Oracle and/or its affiliates
  11. Micronaut features: Test Resources 1. Automatic provisioning of external resources

    needed during development or testing. • Containers, binaries, etc. 2. Built-in support: 3. Integrated with JUnit Platform (JUnit / Spock / Kotest) for zero-configuration Testcontainers. 14 Copyright © 2024, Oracle and/or its affiliates • MariaDB • MySQL • Oracle • PostgreSQL • SQL Server • Elasticsearch • Redis • MongoDB • Neo4j • Hashicorp Vault • Kafka • RabbitMQ • MQTT • Localstack
  12. Micronaut features: Serialization 1. Drop-in replacement for Jackson Databind, compile-time

    and reflection free. 2. Supports (most of) Jackson, JSON-B and BSON annotations. 3. Why? • Memory performance: 10x smaller runtime footprint. • Security: serializable classes must be opt-in. • Type-safety: Micronaut Serialization performs checks at compile-time (vs Jackson runtime exceptions). • Runtime portability: Micronaut Serialization at runtime supports different annotation sets. 15 Copyright © 2024, Oracle and/or its affiliates
  13. Micronaut features: misc 1. Dependency injection. • Can use JSR-330

    (@Inject) or Spring (@Autowired) annotations. 2. Configuration. • Properties, YAML, TOML, Groovy, Config4K. 3. Validation support. • Built-in: reflection free, faster startup, smaller JAR, reduced memory. • Hibernate Validation: full Bean Validation API compliance. 4. AOP: Aspect-Oriented Programming. • Compile-time, reflection free. 16 Copyright © 2024, Oracle and/or its affiliates
  14. Micronaut features: misc 1. Distributed Tracing. • Zipkin, Jaegger. 2.

    Service Discovery and Distributed Configuration. • Consul, Eureka, Kubernetes. 3. Monitoring. • Micrometer, JMX, Elasticsearch. 4. API development. • GraphQL, GRPC, Open API. 5. Containers. • Docker, Kubernetes, Testcontainers. 6. Cache. • Jcache, Redis, Ehcache, Hazelcast, Infinispan, Oracle Coherence. 7. Email. 8. Error handling. 17 Copyright © 2024, Oracle and/or its affiliates
  15. Micronaut 4: what’s new 1. Java 17 required. • Virtual

    threads support (Project Loom). • @Client implementation based on java.net.http.HttpClient (JEP 321) • For older versions of Java use Micronaut 3.x. • Other languages • Kotlin 1.8, KSP support. • Apache Groovy 4. 2. GraalVM improvements. • Reachability metadata enabled. • Improved build times and reduced memory consumption. 3. Micronaut Data v4 • Hibernate 6. 23 Copyright © 2024, Oracle and/or its affiliates
  16. Micronaut 4: what’s new 3. Smaller, lighter runtime. • Performance

    closer to raw Netty (~200ms startup). • Some modules spun off core: Service Discovery, Retry, Session, Validation, Websocket. • Some dependencies now optional: Jackson, SnakeYAML, Caffeine. 4. Other features: • HTTP client/server filter methods: annotation-based and without reactive APIs. • Annotation-based CORS configuration. • HTTP/3 support. • Prefer Micronaut Serialization over Jackson. • Disabled cloud environment deduction by default. 24 Copyright © 2024, Oracle and/or its affiliates
  17. Micronaut 4: what’s new 5. Compile-time expression language 25 Copyright

    © 2024, Oracle and/or its affiliates Checked at compile time Checked at compile time
  18. Micronaut 4: what’s new 6. Bean mappers: built-in, type-safe alternative

    to MapStruct for type mapping built on EL. 26 Copyright © 2024, Oracle and/or its affiliates
  19. Micronaut 4 coming soon: source generation 28 Copyright © 2024,

    Oracle and/or its affiliates Generates PersonBuilder at compile-time
  20. Micronaut 4 coming soon: JSON Schema 29 Copyright © 2024,

    Oracle and/or its affiliates Generates META-INF/schemas/llama.schema.json at compile-time
  21. Graal A full stack for the development and deployment of

    high performance Java cloud native applications
  22. What is Graal Development Kit for Micronaut? Copyright © 2024,

    Oracle and/or its affiliates 32 BUILT FOR GRAALVM NATIVE IMAGE Easily compile ahead-of-time with GraalVM Native Image into small executables that start instantly, and use less memory/CPU. CLOUD-AGNOSTIC MODULES A curated set of Micronaut modules that provide platform-independent support for core cloud services – object store, secrets, streaming, and more. DEV TOOLS AND VS CODE EXTENSIONS Dev tools to generate multicloud application starter templates. VS Code extensions for local development and cloud deployment.
  23. Native Image Goals Low Resource Usage Start Fast Compact Packaging

    Minimize Vulnerability Copyright © 2024, Oracle and/or its affiliates 38
  24. Micronaut and GraalVM 6ms As low as startup time 18MB

    Consuming memory footprint >30% Increased throughput up to and reduced latency
  25. Micronaut and GraalVM 1. The best integration possibly, supported by

    teams working together at Oracle Labs. • GraalVM EE includes optimisations for Micronaut for increased performance and throughput. • GraalVM EE license included in Oracle Cloud. 2. Micronaut is ready for GraalVM Native Image since day 1. • No reflection, no runtime proxies, no bytecode generation, no dynamic classloading. 3. GraalVM tooling for Visual Studio Code and Intellij IDEA. 40 Copyright © 2024, Oracle and/or its affiliates
  26. GraalVM Reachability Metadata Repository Community-driven collection of GraalVM reachability metadata

    for open-source libraries. • Actively maintained by a collective effort of VMware, Oracle and others. • Enabled in GraalVM Native Build Tools (Maven and Gradle plugins). • Integrated by default in Spring Boot and Micronaut. 41 Copyright © 2024, Oracle and/or its affiliates
  27. Micronaut is the fastest to startup 42 Copyright © 2024,

    Oracle and/or its affiliates Source: https://speakerdeck.com/mraible/comparing-native-java-rest-api-frameworks-jchampions-conference-2024
  28. Micronaut is the fastest to startup 43 Copyright © 2024,

    Oracle and/or its affiliates Source: https://speakerdeck.com/mraible/comparing-native-java-rest-api-frameworks-jchampions-conference-2024
  29. Micronaut consumes the less memory 44 Copyright © 2024, Oracle

    and/or its affiliates Source: https://speakerdeck.com/mraible/comparing-native-java-rest-api-frameworks-jchampions-conference-2024
  30. Micronaut and GraalVM powering Disney+ 45 Copyright © 2024, Oracle

    and/or its affiliates https://aws.amazon.com/blogs/opensource/improving-developer-productivity-at-disney-with-serverless-and-open-source/