Skip to content

Commit

Permalink
change native image doc (#2798)
Browse files Browse the repository at this point in the history
Signed-off-by: crazyhzm <crazyhzm@gmail.com>
  • Loading branch information
CrazyHZM committed Aug 28, 2023
1 parent df5e9d7 commit 5f39cf7
Showing 1 changed file with 53 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
aliases:
- /zh/docs3-v2/java-sdk/advanced-features-and-usage/performance/support-graalvm/
- /zh-cn/docs3-v2/java-sdk/advanced-features-and-usage/performance/support-graalvm/
description: Dubbo 支持 Graal VM
linkTitle: 支持 Graal VM
description: Dubbo 支持 GraalVM Native Image
linkTitle: 支持 GraalVM Native Image
title: 支持 Graal VM
type: docs
weight: 40
Expand All @@ -13,21 +13,21 @@ weight: 40


## 功能说明
Dubbo3.2 支持 Native-Image 文档, 本文档将介绍将 dubbo3.0 项目接入 GraalVM,进行 native-image 编译为二进制的流程
Dubbo3.2 支持 Native-Image 文档, 本文档将介绍将 dubbo3.x 项目接入 GraalVM Native Image,进行 native-image 编译为二进制的流程以及目前支持的组件

关于 GraalVm 的更多信息可以阅读 https://www.graalvm.org/docs/getting-started/container-images/ 此文档。

## 使用场景
- 本机映像编译:将应用程序预编译为本机映像,缩短启动时间并减少内存使用。

- 语言互操作:GraalVM 能够用多种语言编写代码,在同一应用程序中进行互操作。

- 优化:GraalVM 为用 Java、JavaScript 和其他语言编写的应用程序提供优化,提高 Dubbo 应用程序的性能。

- Polyglot 调试:GraalVM 能够在同一会话中调试用多种语言编写的代码,对复杂 Dubbo 应用程序中的问题进行故障排除时非常有用。

- Java 运行时:可以在 GraalVM 上运行,提供更快、更高效的 Java 运行时环境。

- 开发微服务:可以与 GraalVM 结合,创建高性能、低资源利用率的微服务。

## 使用方式
Expand All @@ -37,8 +37,6 @@ Dubbo3.2 支持 Native-Image 文档, 本文档将介绍将 dubbo3.0 项目接入
1. 在Graalvm官网根据自己的系统选取对应Graalvm版本:https://www.graalvm.org/downloads/
2. 根据官方文档安装native-image:https://www.graalvm.org/latest/reference-manual/native-image/#install-native-image



### 第二步:配置profiles

其中包括maven-compiler-plugin、spring-boot-maven-plugin、native-maven-plugin、dubbo-maven-plugin,修改dubbo-maven-plugin中的mainClass为所需的启动类全路径。(其中API使用方式无需添加spring-boot-maven-plugin依赖。)
Expand Down Expand Up @@ -72,7 +70,7 @@ Dubbo3.2 支持 Native-Image 文档, 本文档将介绍将 dubbo3.0 项目接入
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.20</version>
<version>0.9.25</version>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<metadataRepository>
Expand Down Expand Up @@ -115,7 +113,7 @@ Dubbo3.2 支持 Native-Image 文档, 本文档将介绍将 dubbo3.0 项目接入

### 第三步:在Pom依赖中添加native相关的依赖:

其中API使用方式无需添加dubbo-config-spring6依赖。
**其中API使用方式无需添加dubbo-config-spring6依赖**

```xml
<dependency>
Expand All @@ -130,11 +128,7 @@ Dubbo3.2 支持 Native-Image 文档, 本文档将介绍将 dubbo3.0 项目接入
</dependency>
```

### 第四步:调整compiler、proxy、serialization和logger

- 序列化方式目前支持的比较好的是Fastjson2
- compiler、proxy目前只能选择jdk
- logger目前需要配置slf4j,目前仅支持logback
### 第四步:配置应用

示例配置如下:

Expand All @@ -143,7 +137,6 @@ dubbo:
application:
name: ${spring.application.name}
logger: slf4j
compiler: jdk
protocol:
name: dubbo
port: -1
Expand All @@ -156,10 +149,8 @@ dubbo:
metadata-report:
address: zookeeper://127.0.0.1:2181
provider:
proxy: jdk
serialization: fastjson2
consumer:
proxy: jdk
serialization: fastjson2
```

Expand All @@ -182,3 +173,48 @@ dubbo:
### 第六步:执行二进制文件即可

二进制文件在target/目录下,一般以工程名称为二进制包的名称,比如target/native-demo

## 支持的组件以及对应的版本

### 日志组件

| 组件名称 | 所需的插件 | 插件版本 | 备注 |
| ---------------------- | ------------------------ | ---------------------- | ------------------- |
| Apache Commons Logging | native-maven-plugin | 0.9.24 及其以上 | |
| JDK Logger | native-maven-plugin | 0.9.24 及其以上 | |
| slf4j | spring-boot-maven-plugin | 3.x.x (用最新版本即可) | |
| Log4j | | | 计划推动GraalVM支持 |
| Log4j2 | | | |

### 序列化组件

| 组件名称 | 所需的插件 | 插件版本 | 备注 |
| ------------ | ------------------- | --------------------------------------- | ---------------------------- |
| FastJson2 | dubbo-maven-plugin | 3.3.0-beta.1-SNAPSHOT (Preview)及其以上 | |
| JDK | native-maven-plugin | 0.9.24 及其以上 | |
| Hessian-Lite | | | 对JDK 17支持不友好,暂不支持 |

### 注册中心组件

| 组件名称 | 所需的插件 | 插件版本 | 备注 |
| --------- | ------------------ | ------------------------------- | ------------------------ |
| Zookeeper | dubbo-maven-plugin | 3.3.0-beta.1-SNAPSHOT (Preview) | 仅支持Zookeeper Curator5 |

### 元数据中心组件

| 组件名称 | 所需的插件 | 插件版本 | 备注 |
| --------- | ------------------ | ------------------------------- | ------------------------ |
| Zookeeper | dubbo-maven-plugin | 3.3.0-beta.1-SNAPSHOT (Preview) | 仅支持Zookeeper Curator5 |

### 配置中心组件

| 组件名称 | 所需的插件 | 插件版本 | 备注 |
| --------- | ------------------ | ------------------------------- | ------------------------ |
| Zookeeper | dubbo-maven-plugin | 3.3.0-beta.1-SNAPSHOT (Preview) | 仅支持Zookeeper Curator5 |

### 可观测性组件

| 组件名称 | 所需的插件 | 插件版本 | 备注 |
| ---------- | ---------- | -------- | ---- |
| Micrometer | | | |

0 comments on commit 5f39cf7

Please sign in to comment.