如何最小化 jhipster 微服务环境的内存占用?
how to minimize the memory footprint for a jhipster microservice environment?
创建基本微服务环境后:
- 注册表: jhipster-注册表
- 用户计费与授权:jhipster-uaa
- 网关: jhipster-网关
- 微服务: jhipster-微服务
我在设置环境变量时 运行 内存不足:
JAVA_OPTS='-Xmx512m'
我的电脑自带8Go(系统使用2Go)
jhipster-registry 通过 ./mvnw
启动
jhipster-{uaa, gateway, microservice, foo} 通过 ./gradlew
启动
感谢您的帮助
注意: 用于生成那些应用程序的 jh 文件下方
# documentation https://www.jhipster.tech/jdl/
application {
config {
baseName uaa,
packageName fr.org.foo.uaa,
applicationType uaa,
serverPort 9999,
buildTool gradle,
clientPackageManager npm,
nativeLanguage en,
languages [en,fr],
enableTranslation true,
authenticationType uaa,
cacheProvider hazelcast,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
searchEngine elasticsearch,
enableHibernateCache true,
serviceDiscoveryType eureka,
testFrameworks [gatling,cucumber],
skipClient true
}
entities Workflow, Task, Command
}
application {
config {
baseName gateway,
packageName fr.org.foo.gateway,
applicationType gateway,
serverPort 8080,
buildTool gradle,
clientPackageManager npm,
nativeLanguage en,
languages [en,fr],
enableTranslation true,
authenticationType uaa,
uaaBaseName "uaa",
cacheProvider hazelcast,
websocket spring-websocket,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
searchEngine elasticsearch,
enableHibernateCache true,
serviceDiscoveryType eureka,
clientFramework react,
testFrameworks [gatling,cucumber,protractor],
jhiPrefix jhi
}
entities Workflow, Task, Command
}
application {
config {
baseName foo,
packageName fr.org.foo.foo,
applicationType microservice,
serverPort 8081,
buildTool gradle,
clientPackageManager npm,
nativeLanguage en,
languages [en,fr],
enableTranslation true,
authenticationType uaa,
uaaBaseName "uaa",
cacheProvider hazelcast,
websocket spring-websocket,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
searchEngine elasticsearch,
enableHibernateCache true,
serviceDiscoveryType eureka,
testFrameworks [gatling,cucumber],
jhiPrefix jhi
}
entities Workflow, Task, Command
}
entity Workflow {
id Long required,
name String required minlength(3),
description String
}
entity Task {
id Long required,
name String required minlength(3),
type TaskType required,
description String
}
# http://www.workflowpatterns.com/patterns/
enum TaskType {
Sequence,
Split,
Synchronization,
ExclusiveChoice,
SimpleMerge
}
entity Command {
id Long required,
command String required minlength(3),
parameters String,
version String required
}
relationship OneToMany {
Workflow{task} to Task,
Task{command} to Command
}
relationship ManyToOne {
Task{previous} to Task
Task{next} to Task
}
microservice Workflow, Task, Command with foo
您确定 JAVA_OPTS 被 mvnw 或 gradlew 使用了吗?
就个人而言,我在 spring-boot-maven-plugin 配置的 pom.xml 中设置了 JVM args:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
...
<configuration>
<executable>true</executable>
<fork>true</fork>
<mainClass>${start-class}</mainClass>
<jvmArguments>-Xms64m -Xmx128m</jvmArguments>
</configuration>
</plugin>
gradle
也有类似的设置
bootRun {
jvmArgs = ["-Xms64m", "-Xmx128m"]
}
创建基本微服务环境后:
- 注册表: jhipster-注册表
- 用户计费与授权:jhipster-uaa
- 网关: jhipster-网关
- 微服务: jhipster-微服务
我在设置环境变量时 运行 内存不足:
JAVA_OPTS='-Xmx512m'
我的电脑自带8Go(系统使用2Go)
jhipster-registry 通过 ./mvnw
启动jhipster-{uaa, gateway, microservice, foo} 通过 ./gradlew
启动感谢您的帮助
注意: 用于生成那些应用程序的 jh 文件下方
# documentation https://www.jhipster.tech/jdl/
application {
config {
baseName uaa,
packageName fr.org.foo.uaa,
applicationType uaa,
serverPort 9999,
buildTool gradle,
clientPackageManager npm,
nativeLanguage en,
languages [en,fr],
enableTranslation true,
authenticationType uaa,
cacheProvider hazelcast,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
searchEngine elasticsearch,
enableHibernateCache true,
serviceDiscoveryType eureka,
testFrameworks [gatling,cucumber],
skipClient true
}
entities Workflow, Task, Command
}
application {
config {
baseName gateway,
packageName fr.org.foo.gateway,
applicationType gateway,
serverPort 8080,
buildTool gradle,
clientPackageManager npm,
nativeLanguage en,
languages [en,fr],
enableTranslation true,
authenticationType uaa,
uaaBaseName "uaa",
cacheProvider hazelcast,
websocket spring-websocket,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
searchEngine elasticsearch,
enableHibernateCache true,
serviceDiscoveryType eureka,
clientFramework react,
testFrameworks [gatling,cucumber,protractor],
jhiPrefix jhi
}
entities Workflow, Task, Command
}
application {
config {
baseName foo,
packageName fr.org.foo.foo,
applicationType microservice,
serverPort 8081,
buildTool gradle,
clientPackageManager npm,
nativeLanguage en,
languages [en,fr],
enableTranslation true,
authenticationType uaa,
uaaBaseName "uaa",
cacheProvider hazelcast,
websocket spring-websocket,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
searchEngine elasticsearch,
enableHibernateCache true,
serviceDiscoveryType eureka,
testFrameworks [gatling,cucumber],
jhiPrefix jhi
}
entities Workflow, Task, Command
}
entity Workflow {
id Long required,
name String required minlength(3),
description String
}
entity Task {
id Long required,
name String required minlength(3),
type TaskType required,
description String
}
# http://www.workflowpatterns.com/patterns/
enum TaskType {
Sequence,
Split,
Synchronization,
ExclusiveChoice,
SimpleMerge
}
entity Command {
id Long required,
command String required minlength(3),
parameters String,
version String required
}
relationship OneToMany {
Workflow{task} to Task,
Task{command} to Command
}
relationship ManyToOne {
Task{previous} to Task
Task{next} to Task
}
microservice Workflow, Task, Command with foo
您确定 JAVA_OPTS 被 mvnw 或 gradlew 使用了吗?
就个人而言,我在 spring-boot-maven-plugin 配置的 pom.xml 中设置了 JVM args:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
...
<configuration>
<executable>true</executable>
<fork>true</fork>
<mainClass>${start-class}</mainClass>
<jvmArguments>-Xms64m -Xmx128m</jvmArguments>
</configuration>
</plugin>
gradle
也有类似的设置bootRun {
jvmArgs = ["-Xms64m", "-Xmx128m"]
}