Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.34k stars 1.98k forks source link

[FEATURE REQ] Support building native images for Spring Cloud Azure using Spring Native #28053

Closed moarychan closed 2 years ago

moarychan commented 2 years ago

Context

More and more Spring Boot applications are pursuing an instant startup, instant peak performance, and reduced memory consumption. The Spring team has also helped to provide the Spring Native framework, and it will be officially GA soon, it is necessary for us to support Spring Native for all Spring Cloud Azure libraries.

The Azure SDK level is ready to support the Graal VM native image compiler, although it has not released any version. But there is no available solution for Spring Cloud Azure users to build Native Image when using Spring Cloud Azure libraries. And some Spring Cloud Azure users have proposed to build applications based on Spring Native: https://github.com/Azure/azure-sdk-for-java/issues/20489.

Goal

Based on JDK 11, the latest Spring Native (the current version is 0.11.3), and Graal VM SDK (The current version is 22.0.0.2) versions, the beta version should be provided as early as possible to support. Include the following:

Solution

Spring Cloud Azure libraries will follow the Spring Native pattern to build a native executable image, a configuration module called spring-cloud-azure-native-configuration is added to find out the additional configuration for Spring Cloud Azure level, this module is required to combine the dependency Spring Native to build a native image. It needs to meet the following requirements:

stliu commented 2 years ago

Support adding spring native capability for Spring Cloud Azure libraries in Spring Initializr Spring developers can add Azure Support, Spring Native, Azure Native Support, in Spring Initializr, then the application can be built to a native executable or a container containing a native executable.

About the experience on Spring Initializr, I don' think we need a Azure Native Support in spring initialize. But we need to make sure when a user chooses "Spring Native" and "Azure Support", the generated pom is correctly confined.

Since by choose above two dependencies, it is clearly meaning that the user wants to

  1. Build a Spring Native application
  2. Use Spring Cloud Azure

Spring Initializr is scenario based, we don't want to break this experience

stliu commented 2 years ago

@moarychan here is my thoughts of the goal of this feature


Goal

  1. Users should be able to use Spring Cloud Azure within their Spring Native enabled applications.
  2. Users should be able to migrate their existing spring boot application (Spring Cloud Azure included) to Spring Native ones easily, idealy by simply add a dependency or configuration properties change, should not require code change
  3. When user is creating new project on https://start.spring.io, the generated project should be spring native ready if 'Spring Native' and 'Spring Cloud Azure' are listed as project dependency
  4. Documentation - We should provide document about how to use Spring Cloud Azure within Spring Native environment.
  5. Toturial - user should be able to follow a toturial to build a spring cloud azure application using one or more azure service
Netyyyy commented 2 years ago

close in #28158

moarychan commented 2 years ago

Add a perf data reference, it's tested through Spring Cloud Azure Starter Blob and Azure Storage Blob Emulator:

Env info: Windows 11, i5-1135G7 @ 2.4GHz, 16G; Jdk 11.0.15; Graal VM CE-Java11-22.0.0.2; Azure Storage Blob Emulator; Spring Boot 2.6.6; Spring Native 0.11.4; Spring Cloud Azure Starter Storage Blob 4.1.0;

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

BOOT + REST for first Response Memory (Seconds) |   |   |   -- | -- | -- | -- Tech stack | BOOT | REST | REST to write and read with Storage Blob Spring Web + Spring Cloud Azure Storage Blob + JVM | 2.551 Seconds | 0.101 Seconds | 1.108 Seconds Spring Web + Spring Cloud Azure Storage Blob + Spring Native + Graal VM | 0.297 Seconds | 0.009 Seconds | 0.274 Seconds   |   |   |   BOOT + REST First Response Time (Megabytes) |   |   |   Tech stack | BOOT | REST | REST to write and read with Storage Blob Spring Web + Spring Cloud Azure Storage Blob + JVM | 258 M | 271 M | 326 M Spring Web + Spring Cloud Azure Storage Blob + Spring Native + Graal VM | 33 M | 33 M | 41 M