SlideShare ist ein Scribd-Unternehmen logo
1 von 86
Downloaden Sie, um offline zu lesen
Microservices with Micronaut
2021-10-07 - Moritz Kammerer
About me
● 2013 M.Sc. Computer Science @ Munich
University of Applied Sciences
● 2013 Software Engineer @ QAware
● …
● 2021 Expert Software Engineer @ QAware
Working on backend stuff, mostly Java.
LinkedIn | GitHub | moritz.kammerer@qaware.de
Why Cloud?
What’s the problem?
Why does it take so long?
● Start time of Spring (Boot)
○ Depends on the number of beans in the context
○ Reading of bytecode [3]
○ Creating proxies at runtime
○ Runtime AOP
○ Reflection
○ Annotation Synthesizing [1] [2]
● Memory usage
○ Reflective Metadata Cache
● Debugging
○ Very very long stacktraces
○ … with code in dynamically generated proxy classes
[1] https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/annotation/AnnotationUtils.html
[2] https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/annotation/AliasFor.html
[3] https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/type/classreading/AbstractRecursiveAnnotationVisitor.java
Micronaut to the rescue!
What’s the (promised) solution?
● Create stuff at compile time
○ Proxies
○ Dependency Injection
○ AOP
● Why?
○ Compiled once, run often
○ Tradeoff: Compile time vs. Runtime
● Goal:
○ No reflection - or as little as possible
○ No proxies
○ Minimize startup time
○ Minimize memory usage
○ Readable stacktraces
And how does that work?
● Annotation Processor
○ Reads bytecode & annotations of the classes
○ Creates new classes
○ Doesn’t touch your code, just extends it
● Gradle
○ annotationProcessor "io.micronaut:micronaut-inject-java"
○ annotationProcessor "io.micronaut:micronaut-validation"
● Also runs with Maven
○ < Insert 500 KB of XML here >
Well, classpath scanning and reflection
is slow, deal with it...
And this is really working?
● Spring Boot 2.1.2 (starter-web), Java 11, @Component on empty class
○ 0 Beans: 1.236 seconds
○ 1000 Beans: 1.808 seconds
○ 2000 Beans: 2.356 seconds
○ 4000 Beans: 3.259 seconds
○ 8000 Beans: 6.498 seconds
○ 16000 Beans: 9.231 seconds
And this is really working?
● Micronaut 1.0.4, Java 11, @Singleton on empty class
○ 0 Beans: 1085ms
○ 1000 Beans: 1870ms
○ 2000 Beans: 2757ms
○ 4000 Beans: 4529ms
○ 8000 Beans: 8038ms
○ 16000 Beans: 15861ms
Hmmmm...
Debunked: It’s not the classpath scanning
● Not so expensive:
○ Classpath scanning (Spring)
○ Injection with reflection (Spring)
● Expensive
○ Class Loading (Micronaut + Spring)
○ Runtime AOP Proxies (Spring)
○ Annotation Synthesizing (Spring)
○ Read bytecode on big classes (Spring)
○ Auto-Configuration Magic (Spring)
● Most of the expensive stuff is done at Micronaut compile time
Benchmarking is hard!
● This was NOT a real benchmark
● Most time spent in the applications shown on the first slides: Spring
autoconfiguration magic
● It really depends on the needed feature of your application
○ Actuator
○ JPA / Hibernate
○ Tracing
○ Metrics
○ @FeignClient
○ @Transactional
○ @Cacheable
○ …
● Real benchmarks later in the slides :)
Looks great, so not disadvantages?
The price you pay: Compile time (16k Beans)
Spring:
[INFO] Total time: 7.958 s
Micronaut:
BUILD SUCCESSFUL in 5m 3s
Okay... what else does Micronaut bring to the table?
● Dependency Injection
○ @Inject, @Named, @Singleton, @Prototype, ...
● REST Controller
○ @Controller, @GET, @POST, …
● Events
○ @PostConstruct
○ @EventListener
● AOP
○ Around Advice, Introduction Advice, …
● Validation
○ @Validated, @NotNull, ...
...
● Caching
○ @Cachable, @CacheInvalidate, …
● Retry
○ @Retryable
● Circuit Breaking
○ @CircuitBreaker
● Fallback / Recovery
○ @Recoverable / @Fallback
● Scheduling
○ @Scheduled
...
● Reactive & Blocking HTTP with Netty
○ Compile Time Route Validation
○ @Error Exception Handling ala Spring
● Websocket Server & Clients
● Server side views
○ Thymeleaf, Handlebars, Velocity
● OpenAPI / Swagger
○ Open API spec is created on compile time!
● HTTP Clients
○ @Client
○ Client-side load balancing
○ Service discovery (Consul, Eureka, K8S, Route 53, DNS based)
○ OpenTracing (Zipkin, Jaeger)
...
● Application Configuration
○ application.yml / .json / .groovy
○ Different Environments
○ Property Sources (ENV, System Properties, …)
○ @ConfigurationProperties, @Value
○ Distributed config with Consul, AWS Parameter Store
● Database support
○ JPA, Mongo, Neo4J, Postgres-Reactive, Redis, Cassandra
● Monitoring
○ @Endpoint (/beans, /info, /health, …)
○ Metrics with Micrometer
○ Change log level at runtime
...
● Security
○ Like Spring Security with users and roles (RBAC)
○ Basic Auth / Session based
○ JWT (JWS and JWE) incl. automatic token propagation
○ Auth with LDAP
● Function-as-a-Service (AWS Lambda, OpenFaaS)
● Message driven services (RabbitMQ / Kafka)
● CLI applications
● Good documentation!
○ e.g. with tutorials for Let’s Encrypt, starting Consul, etc.
Enough bla bla, show code!
Service to be
written github.com
My browser
HTTP Server
HTTP Client
The Internet
Bootstrapping a project
mn create-app --build=maven demo
Create the HTTP endpoint
Dependency Injection
Message: No bean of type [demo.service.ProjectService] exists.
Path Taken: new ProjectsController(ProjectService projectService) --> new ProjectsController([ProjectService
projectService])
Failed to inject value for parameter [projectService] of class: demo.ProjectsController
Service to be
written github.com
My browser
HTTP Server
HTTP Client
The Internet
Create the HTTP client
https://api.github.com/search/repositories?q=stars:%3E1&sort=stars
Caching
application.yml
1st request 2nd, 3rd, ... request
Failure Recovery
Scheduled beans
Reading configuration values
application.yml
Benchmarks
Spring vs. Micronaut - GitHub Scraper
Micronaut 2.2.1
BUILD SUCCESSFUL in 3s
0,89s user 0,07s system 22% cpu 4,199 total
Startup completed in 625ms
Spring vs. Micronaut - GitHub Scraper
Spring 2.4.1
BUILD SUCCESSFUL in 1s
0,86s user 0,09s system 67% cpu 1,414 total
Started DemoApplication in 1.21 seconds (JVM running for 1.556)
Micronaut (JAR: 14.8 MB)
java -Xms16M -Xmx512M -jar github-scraper-0.1-all.jar / OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
Micronaut
wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars
Running 30s test @ http://localhost:8080/github/stars
8 threads and 80 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 2.21ms 5.33ms 139.33ms 91.82%
Req/Sec 15.22k 5.34k 27.39k 72.74%
Latency Distribution
50% 286.00us
75% 1.98ms
90% 6.44ms
99% 22.34ms
2765210 requests in 30.07s, 1.38GB read
Requests/sec: 91956.68
Transfer/sec: 47.01MB
Spring Boot (JAR: 30.6 MB)
java -Xms16M -Xmx512M -jar github-scraper-spring-0.0.1-SNAPSHOT.jar / OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
Spring Boot
wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars
Running 30s test @ http://localhost:8080/github/stars
8 threads and 80 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 10.23ms 65.15ms 778.07ms 97.82%
Req/Sec 9.29k 2.69k 14.24k 78.93%
Latency Distribution
50% 0.87ms
75% 1.55ms
90% 3.36ms
99% 414.50ms
2169903 requests in 30.10s, 1.07GB read
Requests/sec: 72091.42
Transfer/sec: 36.38MB
How much RAM do I have to use?
Minimal Heap Size - Micronaut (-Xmx32M)
Minimal Heap Size - Micronaut (-Xmx32M)
wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars
Running 30s test @ http://localhost:8080/github/stars
8 threads and 80 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 2.68ms 6.40ms 135.54ms 91.54%
Req/Sec 11.34k 4.58k 23.37k 68.22%
Latency Distribution
50% 270.00us
75% 2.58ms
90% 8.02ms
99% 27.00ms
1717518 requests in 30.06s, 631.95MB read
Socket errors: connect 0, read 0, write 0, timeout 80
Requests/sec: 57134.45
Transfer/sec: 21.02MB
Minimal Heap Size - Spring (-Xmx32M)
Minimal Heap Size - Spring (-Xmx32M)
wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars
Running 30s test @ http://localhost:8080/github/stars
8 threads and 80 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 16.38ms 87.16ms 955.97ms 97.33%
Req/Sec 3.92k 1.19k 6.21k 75.93%
Latency Distribution
50% 2.11ms
75% 4.21ms
90% 8.59ms
99% 578.98ms
905844 requests in 30.05s, 457.16MB read
Requests/sec: 30148.82
Transfer/sec: 15.22MB
Minimal Heap Size - Spring (-Xmx64M)
Minimal Heap Size - Spring (-Xmx64M)
wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars
Running 30s test @ http://localhost:8080/github/stars
8 threads and 80 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 10.50ms 66.17ms 786.18ms 97.73%
Req/Sec 8.60k 2.27k 13.25k 79.23%
Latency Distribution
50% 0.95ms
75% 1.68ms
90% 3.30ms
99% 423.31ms
2006502 requests in 30.09s, 0.99GB read
Requests/sec: 66689.38
Transfer/sec: 33.66MB
Minimal Heap Size - Micronaut (-Xmx64M)
Minimal Heap Size - Micronaut (-Xmx64M)
wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars
Running 30s test @ http://localhost:8080/github/stars
8 threads and 80 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 2.28ms 5.05ms 95.77ms 90.92%
Req/Sec 14.11k 5.15k 25.09k 73.51%
Latency Distribution
50% 283.00us
75% 2.12ms
90% 6.78ms
99% 23.54ms
2451595 requests in 30.06s, 1.22GB read
Requests/sec: 81556.51
Transfer/sec: 41.69MB
Graal VM
“High-performance polyglot VM”
(and AOT compiler)
Graal Substrate VM
$ ./gradlew nativeImage (or ./mvnw package -Dpackaging=native-image)
… 2 minutes later …
$ file application
application: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2 for GNU/Linux 3.2.0, with debug_info, not stripped
$ ll application
-rwxr-xr-x. 1 moe moe 62M 18. Dez 11:29 application
$ ldd application
linux-vdso.so.1 (0x00007ffd7cbbe000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc717414000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fc71740d000)
libz.so.1 => /lib64/libz.so.1 (0x00007fc7173f3000)
librt.so.1 => /lib64/librt.so.1 (0x00007fc7173e8000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc7173cd000)
libc.so.6 => /lib64/libc.so.6 (0x00007fc717202000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc717456000)
Graal (no -Xmx set)
KB = 92 MB
Idle:
Under load:
Startup completed in 67ms.
Graal - Benchmark
wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars
Running 30s test @ http://localhost:8080/github/stars
8 threads and 80 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.60ms 2.28ms 41.76ms 86.51%
Req/Sec 8.88k 1.21k 12.09k 79.71%
Latency Distribution
50% 416.00us
75% 2.34ms
90% 4.61ms
99% 10.16ms
1355757 requests in 30.04s, 305.29MB read
Socket errors: connect 0, read 0, write 0, timeout 80
Requests/sec: 45130.28
Transfer/sec: 10.16MB
Conclusion
Experience from the trenches
Pro:
● Services start faster than Spring Boot
● Smaller JARs
● Tests are faster, as the embedded server starts fast
○ Spring mitigates this with application context caching!
Contra:
● No separation of management and API port
● Spring Boot is more common (more documentation, blog posts, Stack
Overflow answers)
● Extension story from Spring is better (e.g. OAuth2)
Conclusion
● Good documentation
● Recommendation for writing small services
○ I have no experience with bigger services in Micronaut. If you have, please contact me :)
● Development is fun
● If the features are sufficient: Try it!
● GraalVM Substrate VM, if you get it to run, is really cool
○ This is NOT a JVM, so profilers / metrics / thread dumps etc. won’t work
○ Build times like it’s C++ (> 30s)
○ Not all libraries are compatible and workarounds must be used
■ I ran into trouble with Caffeine Cache (GitHub Issue)
Literature
● GitHub Repo: https://github.com/qaware/microservices-with-micronaut
● Micronaut documentation: https://docs.micronaut.io/latest/guide/index.html
● GraalVM: https://www.graalvm.org/
Questions?
Contact: moritz.kammerer@qaware.de
Microservices with Micronaut

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

async/awaitダークサイド is 何
async/awaitダークサイド is 何async/awaitダークサイド is 何
async/awaitダークサイド is 何
 
Actionable Agile Metrics for Predictability - Daniel Vacanti
Actionable Agile Metrics for Predictability - Daniel VacantiActionable Agile Metrics for Predictability - Daniel Vacanti
Actionable Agile Metrics for Predictability - Daniel Vacanti
 
Moving from Kanban to scrum
Moving from Kanban to scrumMoving from Kanban to scrum
Moving from Kanban to scrum
 
【Sgt2016】Agile人材の評価とキャリアプラン
【Sgt2016】Agile人材の評価とキャリアプラン 【Sgt2016】Agile人材の評価とキャリアプラン
【Sgt2016】Agile人材の評価とキャリアプラン
 
Codemotion Madrid 2023 - Testcontainers y Spring Boot
Codemotion Madrid 2023 - Testcontainers y Spring BootCodemotion Madrid 2023 - Testcontainers y Spring Boot
Codemotion Madrid 2023 - Testcontainers y Spring Boot
 
今こそ知りたいSpring Web(Spring Fest 2020講演資料)
今こそ知りたいSpring Web(Spring Fest 2020講演資料)今こそ知りたいSpring Web(Spring Fest 2020講演資料)
今こそ知りたいSpring Web(Spring Fest 2020講演資料)
 
Ruby Rails 老司機帶飛
Ruby Rails 老司機帶飛Ruby Rails 老司機帶飛
Ruby Rails 老司機帶飛
 
Testen mit, durch und in Scrum
Testen mit, durch und in ScrumTesten mit, durch und in Scrum
Testen mit, durch und in Scrum
 
今日からできる!簡単 .NET 高速化 Tips
今日からできる!簡単 .NET 高速化 Tips今日からできる!簡単 .NET 高速化 Tips
今日からできる!簡単 .NET 高速化 Tips
 
ドキュメントライブラリを便利にするかも?しれないテクニック
ドキュメントライブラリを便利にするかも?しれないテクニックドキュメントライブラリを便利にするかも?しれないテクニック
ドキュメントライブラリを便利にするかも?しれないテクニック
 
Bdd Introduction
Bdd IntroductionBdd Introduction
Bdd Introduction
 
プロダクトマネージャーにたちはだかる壁を、どう乗り越えるか
プロダクトマネージャーにたちはだかる壁を、どう乗り越えるかプロダクトマネージャーにたちはだかる壁を、どう乗り越えるか
プロダクトマネージャーにたちはだかる壁を、どう乗り越えるか
 
Designing your kanban board to map your process
Designing your kanban board to map your processDesigning your kanban board to map your process
Designing your kanban board to map your process
 
Project Facilitation
Project FacilitationProject Facilitation
Project Facilitation
 
JSRとJEPとJBSの見方や調べ方について
JSRとJEPとJBSの見方や調べ方についてJSRとJEPとJBSの見方や調べ方について
JSRとJEPとJBSの見方や調べ方について
 
Tomcatの実装から学ぶクラスローダリーク #渋谷Java
Tomcatの実装から学ぶクラスローダリーク #渋谷JavaTomcatの実装から学ぶクラスローダリーク #渋谷Java
Tomcatの実装から学ぶクラスローダリーク #渋谷Java
 
Terratest with Terraform
Terratest with TerraformTerratest with Terraform
Terratest with Terraform
 
golang.tokyo #6 (in Japanese)
golang.tokyo #6 (in Japanese)golang.tokyo #6 (in Japanese)
golang.tokyo #6 (in Japanese)
 
Agilité pour les nuls
Agilité pour les nulsAgilité pour les nuls
Agilité pour les nuls
 
プランニングポーカーではじめる工数見積りと計画づくり
プランニングポーカーではじめる工数見積りと計画づくりプランニングポーカーではじめる工数見積りと計画づくり
プランニングポーカーではじめる工数見積りと計画づくり
 

Ähnlich wie Microservices with Micronaut

Best Practices for performance evaluation and diagnosis of Java Applications ...
Best Practices for performance evaluation and diagnosis of Java Applications ...Best Practices for performance evaluation and diagnosis of Java Applications ...
Best Practices for performance evaluation and diagnosis of Java Applications ...
IndicThreads
 

Ähnlich wie Microservices with Micronaut (20)

Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
 
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
 
Software Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and FlamegraphsSoftware Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and Flamegraphs
 
Best Practices for performance evaluation and diagnosis of Java Applications ...
Best Practices for performance evaluation and diagnosis of Java Applications ...Best Practices for performance evaluation and diagnosis of Java Applications ...
Best Practices for performance evaluation and diagnosis of Java Applications ...
 
Netflix Keystone Pipeline at Samza Meetup 10-13-2015
Netflix Keystone Pipeline at Samza Meetup 10-13-2015Netflix Keystone Pipeline at Samza Meetup 10-13-2015
Netflix Keystone Pipeline at Samza Meetup 10-13-2015
 
Introduction to apache kafka
Introduction to apache kafkaIntroduction to apache kafka
Introduction to apache kafka
 
Container Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, NetflixContainer Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, Netflix
 
Container Performance Analysis
Container Performance AnalysisContainer Performance Analysis
Container Performance Analysis
 
Java Memory Model
Java Memory ModelJava Memory Model
Java Memory Model
 
Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !
 
YOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at NetflixYOW2018 Cloud Performance Root Cause Analysis at Netflix
YOW2018 Cloud Performance Root Cause Analysis at Netflix
 
Deep Dive on Amazon EC2 instances
Deep Dive on Amazon EC2 instancesDeep Dive on Amazon EC2 instances
Deep Dive on Amazon EC2 instances
 
Writing Serverless Application in Java with comparison of 3 approaches: AWS S...
Writing Serverless Application in Java with comparison of 3 approaches: AWS S...Writing Serverless Application in Java with comparison of 3 approaches: AWS S...
Writing Serverless Application in Java with comparison of 3 approaches: AWS S...
 
Kubecon seattle 2018 workshop slides
Kubecon seattle 2018 workshop slidesKubecon seattle 2018 workshop slides
Kubecon seattle 2018 workshop slides
 
Hs java open_party
Hs java open_partyHs java open_party
Hs java open_party
 
Java Performance and Profiling
Java Performance and ProfilingJava Performance and Profiling
Java Performance and Profiling
 
Profiling & Testing with Spark
Profiling & Testing with SparkProfiling & Testing with Spark
Profiling & Testing with Spark
 
Open Source XMPP for Cloud Services
Open Source XMPP for Cloud ServicesOpen Source XMPP for Cloud Services
Open Source XMPP for Cloud Services
 

Mehr von QAware GmbH

"Mixed" Scrum-Teams – Die richtige Mischung macht's!
"Mixed" Scrum-Teams – Die richtige Mischung macht's!"Mixed" Scrum-Teams – Die richtige Mischung macht's!
"Mixed" Scrum-Teams – Die richtige Mischung macht's!
QAware GmbH
 
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
 Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
QAware GmbH
 

Mehr von QAware GmbH (20)

50 Shades of K8s Autoscaling #JavaLand24.pdf
50 Shades of K8s Autoscaling #JavaLand24.pdf50 Shades of K8s Autoscaling #JavaLand24.pdf
50 Shades of K8s Autoscaling #JavaLand24.pdf
 
Make Agile Great - PM-Erfahrungen aus zwei virtuellen internationalen SAFe-Pr...
Make Agile Great - PM-Erfahrungen aus zwei virtuellen internationalen SAFe-Pr...Make Agile Great - PM-Erfahrungen aus zwei virtuellen internationalen SAFe-Pr...
Make Agile Great - PM-Erfahrungen aus zwei virtuellen internationalen SAFe-Pr...
 
Fully-managed Cloud-native Databases: The path to indefinite scale @ CNN Mainz
Fully-managed Cloud-native Databases: The path to indefinite scale @ CNN MainzFully-managed Cloud-native Databases: The path to indefinite scale @ CNN Mainz
Fully-managed Cloud-native Databases: The path to indefinite scale @ CNN Mainz
 
Down the Ivory Tower towards Agile Architecture
Down the Ivory Tower towards Agile ArchitectureDown the Ivory Tower towards Agile Architecture
Down the Ivory Tower towards Agile Architecture
 
"Mixed" Scrum-Teams – Die richtige Mischung macht's!
"Mixed" Scrum-Teams – Die richtige Mischung macht's!"Mixed" Scrum-Teams – Die richtige Mischung macht's!
"Mixed" Scrum-Teams – Die richtige Mischung macht's!
 
Make Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform EngineeringMake Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform Engineering
 
Der Tod der Testpyramide? – Frontend-Testing mit Playwright
Der Tod der Testpyramide? – Frontend-Testing mit PlaywrightDer Tod der Testpyramide? – Frontend-Testing mit Playwright
Der Tod der Testpyramide? – Frontend-Testing mit Playwright
 
Was kommt nach den SPAs
Was kommt nach den SPAsWas kommt nach den SPAs
Was kommt nach den SPAs
 
Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo
 
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
 Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
 
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
 
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
 
Kubernetes with Cilium in AWS - Experience Report!
Kubernetes with Cilium in AWS - Experience Report!Kubernetes with Cilium in AWS - Experience Report!
Kubernetes with Cilium in AWS - Experience Report!
 
50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling
 
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAPKontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
 
Service Mesh Pain & Gain. Experiences from a client project.
Service Mesh Pain & Gain. Experiences from a client project.Service Mesh Pain & Gain. Experiences from a client project.
Service Mesh Pain & Gain. Experiences from a client project.
 
50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling
 
Blue turns green! Approaches and technologies for sustainable K8s clusters.
Blue turns green! Approaches and technologies for sustainable K8s clusters.Blue turns green! Approaches and technologies for sustainable K8s clusters.
Blue turns green! Approaches and technologies for sustainable K8s clusters.
 
Per Anhalter zu Cloud Nativen API Gateways
Per Anhalter zu Cloud Nativen API GatewaysPer Anhalter zu Cloud Nativen API Gateways
Per Anhalter zu Cloud Nativen API Gateways
 
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
 

Kürzlich hochgeladen

Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
amitlee9823
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
shivangimorya083
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
shivangimorya083
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
MarinCaroMartnezBerg
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
shambhavirathore45
 

Kürzlich hochgeladen (20)

Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 

Microservices with Micronaut

  • 1.
  • 3. About me ● 2013 M.Sc. Computer Science @ Munich University of Applied Sciences ● 2013 Software Engineer @ QAware ● … ● 2021 Expert Software Engineer @ QAware Working on backend stuff, mostly Java. LinkedIn | GitHub | moritz.kammerer@qaware.de
  • 6. Why does it take so long? ● Start time of Spring (Boot) ○ Depends on the number of beans in the context ○ Reading of bytecode [3] ○ Creating proxies at runtime ○ Runtime AOP ○ Reflection ○ Annotation Synthesizing [1] [2] ● Memory usage ○ Reflective Metadata Cache ● Debugging ○ Very very long stacktraces ○ … with code in dynamically generated proxy classes [1] https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/annotation/AnnotationUtils.html [2] https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/annotation/AliasFor.html [3] https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/type/classreading/AbstractRecursiveAnnotationVisitor.java
  • 8. What’s the (promised) solution? ● Create stuff at compile time ○ Proxies ○ Dependency Injection ○ AOP ● Why? ○ Compiled once, run often ○ Tradeoff: Compile time vs. Runtime ● Goal: ○ No reflection - or as little as possible ○ No proxies ○ Minimize startup time ○ Minimize memory usage ○ Readable stacktraces
  • 9. And how does that work? ● Annotation Processor ○ Reads bytecode & annotations of the classes ○ Creates new classes ○ Doesn’t touch your code, just extends it ● Gradle ○ annotationProcessor "io.micronaut:micronaut-inject-java" ○ annotationProcessor "io.micronaut:micronaut-validation" ● Also runs with Maven ○ < Insert 500 KB of XML here >
  • 10.
  • 11. Well, classpath scanning and reflection is slow, deal with it...
  • 12. And this is really working? ● Spring Boot 2.1.2 (starter-web), Java 11, @Component on empty class ○ 0 Beans: 1.236 seconds ○ 1000 Beans: 1.808 seconds ○ 2000 Beans: 2.356 seconds ○ 4000 Beans: 3.259 seconds ○ 8000 Beans: 6.498 seconds ○ 16000 Beans: 9.231 seconds
  • 13. And this is really working? ● Micronaut 1.0.4, Java 11, @Singleton on empty class ○ 0 Beans: 1085ms ○ 1000 Beans: 1870ms ○ 2000 Beans: 2757ms ○ 4000 Beans: 4529ms ○ 8000 Beans: 8038ms ○ 16000 Beans: 15861ms
  • 15. Debunked: It’s not the classpath scanning ● Not so expensive: ○ Classpath scanning (Spring) ○ Injection with reflection (Spring) ● Expensive ○ Class Loading (Micronaut + Spring) ○ Runtime AOP Proxies (Spring) ○ Annotation Synthesizing (Spring) ○ Read bytecode on big classes (Spring) ○ Auto-Configuration Magic (Spring) ● Most of the expensive stuff is done at Micronaut compile time
  • 16. Benchmarking is hard! ● This was NOT a real benchmark ● Most time spent in the applications shown on the first slides: Spring autoconfiguration magic ● It really depends on the needed feature of your application ○ Actuator ○ JPA / Hibernate ○ Tracing ○ Metrics ○ @FeignClient ○ @Transactional ○ @Cacheable ○ … ● Real benchmarks later in the slides :)
  • 17. Looks great, so not disadvantages?
  • 18. The price you pay: Compile time (16k Beans) Spring: [INFO] Total time: 7.958 s Micronaut: BUILD SUCCESSFUL in 5m 3s
  • 19. Okay... what else does Micronaut bring to the table? ● Dependency Injection ○ @Inject, @Named, @Singleton, @Prototype, ... ● REST Controller ○ @Controller, @GET, @POST, … ● Events ○ @PostConstruct ○ @EventListener ● AOP ○ Around Advice, Introduction Advice, … ● Validation ○ @Validated, @NotNull, ...
  • 20. ... ● Caching ○ @Cachable, @CacheInvalidate, … ● Retry ○ @Retryable ● Circuit Breaking ○ @CircuitBreaker ● Fallback / Recovery ○ @Recoverable / @Fallback ● Scheduling ○ @Scheduled
  • 21. ... ● Reactive & Blocking HTTP with Netty ○ Compile Time Route Validation ○ @Error Exception Handling ala Spring ● Websocket Server & Clients ● Server side views ○ Thymeleaf, Handlebars, Velocity ● OpenAPI / Swagger ○ Open API spec is created on compile time! ● HTTP Clients ○ @Client ○ Client-side load balancing ○ Service discovery (Consul, Eureka, K8S, Route 53, DNS based) ○ OpenTracing (Zipkin, Jaeger)
  • 22. ... ● Application Configuration ○ application.yml / .json / .groovy ○ Different Environments ○ Property Sources (ENV, System Properties, …) ○ @ConfigurationProperties, @Value ○ Distributed config with Consul, AWS Parameter Store ● Database support ○ JPA, Mongo, Neo4J, Postgres-Reactive, Redis, Cassandra ● Monitoring ○ @Endpoint (/beans, /info, /health, …) ○ Metrics with Micrometer ○ Change log level at runtime
  • 23. ... ● Security ○ Like Spring Security with users and roles (RBAC) ○ Basic Auth / Session based ○ JWT (JWS and JWE) incl. automatic token propagation ○ Auth with LDAP ● Function-as-a-Service (AWS Lambda, OpenFaaS) ● Message driven services (RabbitMQ / Kafka) ● CLI applications ● Good documentation! ○ e.g. with tutorials for Let’s Encrypt, starting Consul, etc.
  • 24. Enough bla bla, show code!
  • 25. Service to be written github.com My browser HTTP Server HTTP Client The Internet
  • 27.
  • 28.
  • 30.
  • 31. Create the HTTP endpoint
  • 32.
  • 33.
  • 35.
  • 36.
  • 37. Message: No bean of type [demo.service.ProjectService] exists. Path Taken: new ProjectsController(ProjectService projectService) --> new ProjectsController([ProjectService projectService]) Failed to inject value for parameter [projectService] of class: demo.ProjectsController
  • 38.
  • 39.
  • 40. Service to be written github.com My browser HTTP Server HTTP Client The Internet
  • 41. Create the HTTP client
  • 43.
  • 44.
  • 45.
  • 46.
  • 48.
  • 49.
  • 51. 1st request 2nd, 3rd, ... request
  • 53.
  • 54.
  • 55.
  • 57.
  • 60.
  • 62. Spring vs. Micronaut - GitHub Scraper Micronaut 2.2.1 BUILD SUCCESSFUL in 3s 0,89s user 0,07s system 22% cpu 4,199 total Startup completed in 625ms
  • 63. Spring vs. Micronaut - GitHub Scraper Spring 2.4.1 BUILD SUCCESSFUL in 1s 0,86s user 0,09s system 67% cpu 1,414 total Started DemoApplication in 1.21 seconds (JVM running for 1.556)
  • 64. Micronaut (JAR: 14.8 MB) java -Xms16M -Xmx512M -jar github-scraper-0.1-all.jar / OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
  • 65. Micronaut wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars Running 30s test @ http://localhost:8080/github/stars 8 threads and 80 connections Thread Stats Avg Stdev Max +/- Stdev Latency 2.21ms 5.33ms 139.33ms 91.82% Req/Sec 15.22k 5.34k 27.39k 72.74% Latency Distribution 50% 286.00us 75% 1.98ms 90% 6.44ms 99% 22.34ms 2765210 requests in 30.07s, 1.38GB read Requests/sec: 91956.68 Transfer/sec: 47.01MB
  • 66. Spring Boot (JAR: 30.6 MB) java -Xms16M -Xmx512M -jar github-scraper-spring-0.0.1-SNAPSHOT.jar / OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
  • 67. Spring Boot wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars Running 30s test @ http://localhost:8080/github/stars 8 threads and 80 connections Thread Stats Avg Stdev Max +/- Stdev Latency 10.23ms 65.15ms 778.07ms 97.82% Req/Sec 9.29k 2.69k 14.24k 78.93% Latency Distribution 50% 0.87ms 75% 1.55ms 90% 3.36ms 99% 414.50ms 2169903 requests in 30.10s, 1.07GB read Requests/sec: 72091.42 Transfer/sec: 36.38MB
  • 68. How much RAM do I have to use?
  • 69. Minimal Heap Size - Micronaut (-Xmx32M)
  • 70. Minimal Heap Size - Micronaut (-Xmx32M) wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars Running 30s test @ http://localhost:8080/github/stars 8 threads and 80 connections Thread Stats Avg Stdev Max +/- Stdev Latency 2.68ms 6.40ms 135.54ms 91.54% Req/Sec 11.34k 4.58k 23.37k 68.22% Latency Distribution 50% 270.00us 75% 2.58ms 90% 8.02ms 99% 27.00ms 1717518 requests in 30.06s, 631.95MB read Socket errors: connect 0, read 0, write 0, timeout 80 Requests/sec: 57134.45 Transfer/sec: 21.02MB
  • 71. Minimal Heap Size - Spring (-Xmx32M)
  • 72. Minimal Heap Size - Spring (-Xmx32M) wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars Running 30s test @ http://localhost:8080/github/stars 8 threads and 80 connections Thread Stats Avg Stdev Max +/- Stdev Latency 16.38ms 87.16ms 955.97ms 97.33% Req/Sec 3.92k 1.19k 6.21k 75.93% Latency Distribution 50% 2.11ms 75% 4.21ms 90% 8.59ms 99% 578.98ms 905844 requests in 30.05s, 457.16MB read Requests/sec: 30148.82 Transfer/sec: 15.22MB
  • 73. Minimal Heap Size - Spring (-Xmx64M)
  • 74. Minimal Heap Size - Spring (-Xmx64M) wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars Running 30s test @ http://localhost:8080/github/stars 8 threads and 80 connections Thread Stats Avg Stdev Max +/- Stdev Latency 10.50ms 66.17ms 786.18ms 97.73% Req/Sec 8.60k 2.27k 13.25k 79.23% Latency Distribution 50% 0.95ms 75% 1.68ms 90% 3.30ms 99% 423.31ms 2006502 requests in 30.09s, 0.99GB read Requests/sec: 66689.38 Transfer/sec: 33.66MB
  • 75. Minimal Heap Size - Micronaut (-Xmx64M)
  • 76. Minimal Heap Size - Micronaut (-Xmx64M) wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars Running 30s test @ http://localhost:8080/github/stars 8 threads and 80 connections Thread Stats Avg Stdev Max +/- Stdev Latency 2.28ms 5.05ms 95.77ms 90.92% Req/Sec 14.11k 5.15k 25.09k 73.51% Latency Distribution 50% 283.00us 75% 2.12ms 90% 6.78ms 99% 23.54ms 2451595 requests in 30.06s, 1.22GB read Requests/sec: 81556.51 Transfer/sec: 41.69MB
  • 77. Graal VM “High-performance polyglot VM” (and AOT compiler)
  • 78. Graal Substrate VM $ ./gradlew nativeImage (or ./mvnw package -Dpackaging=native-image) … 2 minutes later … $ file application application: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2 for GNU/Linux 3.2.0, with debug_info, not stripped $ ll application -rwxr-xr-x. 1 moe moe 62M 18. Dez 11:29 application $ ldd application linux-vdso.so.1 (0x00007ffd7cbbe000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc717414000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fc71740d000) libz.so.1 => /lib64/libz.so.1 (0x00007fc7173f3000) librt.so.1 => /lib64/librt.so.1 (0x00007fc7173e8000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc7173cd000) libc.so.6 => /lib64/libc.so.6 (0x00007fc717202000) /lib64/ld-linux-x86-64.so.2 (0x00007fc717456000)
  • 79. Graal (no -Xmx set) KB = 92 MB Idle: Under load: Startup completed in 67ms.
  • 80. Graal - Benchmark wrk -t 8 -c 80 -d 30s --latency http://localhost:8080/github/stars Running 30s test @ http://localhost:8080/github/stars 8 threads and 80 connections Thread Stats Avg Stdev Max +/- Stdev Latency 1.60ms 2.28ms 41.76ms 86.51% Req/Sec 8.88k 1.21k 12.09k 79.71% Latency Distribution 50% 416.00us 75% 2.34ms 90% 4.61ms 99% 10.16ms 1355757 requests in 30.04s, 305.29MB read Socket errors: connect 0, read 0, write 0, timeout 80 Requests/sec: 45130.28 Transfer/sec: 10.16MB
  • 82. Experience from the trenches Pro: ● Services start faster than Spring Boot ● Smaller JARs ● Tests are faster, as the embedded server starts fast ○ Spring mitigates this with application context caching! Contra: ● No separation of management and API port ● Spring Boot is more common (more documentation, blog posts, Stack Overflow answers) ● Extension story from Spring is better (e.g. OAuth2)
  • 83. Conclusion ● Good documentation ● Recommendation for writing small services ○ I have no experience with bigger services in Micronaut. If you have, please contact me :) ● Development is fun ● If the features are sufficient: Try it! ● GraalVM Substrate VM, if you get it to run, is really cool ○ This is NOT a JVM, so profilers / metrics / thread dumps etc. won’t work ○ Build times like it’s C++ (> 30s) ○ Not all libraries are compatible and workarounds must be used ■ I ran into trouble with Caffeine Cache (GitHub Issue)
  • 84. Literature ● GitHub Repo: https://github.com/qaware/microservices-with-micronaut ● Micronaut documentation: https://docs.micronaut.io/latest/guide/index.html ● GraalVM: https://www.graalvm.org/