Instant Weather forecast with Micronaut powered by GraalVM
Weather is generally hard to predict since there are so many variables affecting the outcome. Another important factor is the startup time of the underlying application serving those requests. The expectation is that the user experience should be snappy with a real-time feel.
Outcome
time ./application weather — country SG — city Singapore 03:38:16.651
temperature: 22.0°C
wind speed: 15.76 km/h
cloud coverage: 100.0%
precipitation: 2.1 mm/h
Performance
Traditional Runtime: 3s 980ms
Cloud-Native GraalVM: 285ms
That's approximately 16 times faster when running it as a Cloud Native Application using GraalVM + Micronaut.
Technology
- GitHub: https://github.com/amitpal-source/micronaut-weather-cli
- GraalVM: A High-Performance Virtual Machine that can produce Cloud-Native Applications.
- Micronaut: A modern, JVM-based, full-stack framework for building modular, easily testable microservice and serverless applications
- Oracle Cloud Infrastructure: An IaaS that delivers on-premises, high-performance computing power to run cloud-native and enterprise company’s IT workloads
Techniques
[opc@instance-20201214-2208 native-image]$ time ./application forecast --country SG --city Singapore --days 301:53:55.658 [main] INFO i.m.context.env.DefaultEnvironment - Established active environments: [oraclecloud, cloud, cli]01:53:55.663 [main] INFO w.cli.commands.ForecastSubcommand - Asking weather for city singapore and country sg01:53:55.962 [main] INFO w.cli.commands.ForecastSubcommand - =====================================01:53:55.963 [main] INFO w.cli.commands.ForecastSubcommand - Forecast in singapore on day 2021-01-11:- average temperature: 24.2°C- min temperature: 23.0°C- max temperature: 25.2°C- wind speed: 15.024591720000002 km/h- probability of precipitation: 30.0%- average cloud coverage: 100.0%01:53:55.963 [main] INFO w.cli.commands.ForecastSubcommand - Forecast in singapore on day 2021-01-12:- average temperature: 25.3°C- min temperature: 23.5°C- max temperature: 28.3°C- wind speed: 19.4826222 km/h- probability of precipitation: 60.0%- average cloud coverage: 99.0%01:53:55.963 [main] INFO w.cli.commands.ForecastSubcommand - Forecast in singapore on day 2021-01-13:- average temperature: 25.0°C- min temperature: 23.4°C- max temperature: 27.8°C- wind speed: 17.4903372 km/h- probability of precipitation: 20.0%- average cloud coverage: 100.0%
Acknowledgments
https://dev.to/stack-labs/cli-applications-with-micronaut-and-picocli-4mc8
Collaborative support by Munish Chouhan from Oracle Labs Engineering.