Shocked, Spring Boot consumes so much memory!

In general, Spring Boot is relatively easy to build, especially the Spring Cloud family bucket, referred to as micro-services for the people, but in the development trend, containerization technology has matured. In the face of Spring Boot, which consumes a lot of memory, small companies say they do n’t Up. Nowadays, many newly born JAVA microservice frameworks mostly focus on "lightweight", mainly because Spring Boot is too heavy.

JAVA Microservice Framework

No1-Spring Cloud

Introduction

There is a strong backing for Spring, and the issues of update, stability, and maturity need not be considered at all. The technical staff in the JAVA department have probably heard of the name of Spring, so there is no shortage of programmers ..., and the difficulty of starting is very low, you can save an architect.

However, you must pay on the server:

At least one "service discovery" server;

There may be a unified gateway Gateway;

A configuration center for "distributed configuration management" may be required;

May perform "service tracking" to know where my request comes from and where;

May require "cluster monitoring";

After the project went online, we found that we need a lot of servers, and every time we add servers to the cluster, we feel distressed;

Pressure test for 30 seconds

Memory usage before stress test

Shocked, Spring Boot consumes so much memory!

 

As shown in the figure, the memory occupies 304M.

Memory usage during stress test

Shocked, Spring Boot consumes so much memory!

 

As shown in the figure, the memory occupies 1520M (1.5G), and the CPU rises to 321%

Overview

Shocked, Spring Boot consumes so much memory!

 

to sum up

A simple application of Spring Boot, with a minimum of 1G memory, and a microservice compiled with a relatively small number of business points will have a JAR of about 50M; and Spring Cloud will introduce relatively more components and consume more resources.

Startup time is about 10 seconds: Started Application in 10.153 seconds (JVM running for 10.915)

JAVA-based reactive programming toolkit Vert.x

Introduction

Eclipse Vert.x backed by Eclipse is a toolkit for building responsive applications on the JVM. The positioning does not conflict with Spring Boot, and you can even use Vert.x with Spring Boot. Many Vert.x modules provide a large number of microservice components, which in many people's eyes is a choice of microservice architecture.

Huawei MicroService Framework Apache ServiceComb is implemented with Vert.x as the underlying framework. In the "benchmark test site TechEmpower", Vert.x's performance is also very eye-catching.

Pressure test for 30 seconds

Memory usage before stress test

Shocked, Spring Boot consumes so much memory!

 

As shown in the figure, the memory occupies 65M.

Memory usage during stress test

Shocked, Spring Boot consumes so much memory!

 

As shown in the figure, the memory occupies 139M and the CPU occupies 2.1%. It seems that there is no stress test.

Overview

Shocked, Spring Boot consumes so much memory!

 

to sum up

After the Vert.x single service is packaged, it is about 7M of JAR. It does not depend on containers such as Tomcat and Jetty, and runs directly on the JVM.

Vert.x consumes very low resources. I feel that a 1 core 2G server can already deploy many Vert.x services. Except for coding problems, it truly conforms to small projects and small modules. The open source gateway based on Vert.x has appeared on the git market-VX-API-Gateway help documentation

https://duhua.gitee.io/vx-api-gateway-doc

Support multi-language, very suitable for small projects to go online quickly.

Startup time is less than 1 second: Started Vert.x in 0.274 seconds (JVM running for 0.274)

JAVA Department Other Microservice Framework

Spark Java

  • jar is relatively small, about 10M
  • Small memory, about 30 ~ 60MB;
  • Performance is okay, similar to Spring Boot;

Micronaut

  • The new favorite of the Grails team;
  • Microservice-based applications that can be written in Java, Groovy, and Kotlin;
  • Compared with Spring Boot, it is more comprehensive;
  • The performance is better, and the coding method is similar to Spring Boot;
  • Startup time and memory consumption are more efficient than other frameworks;
  • multi-language;
  • Dependency injection
  • Built-in multiple cloud local functions;
  • Very new, just released 1.0.0

Javalin

  • It is extremely easy to get started;
  • Flexible, compatible with both synchronous and asynchronous programming ideas;
  • JAR is small, 4 ~ 5M;
  • multi-language;
  • There is a shadow of KOA;
  • There are only about 2000 lines of source code, the source code is simple enough to understand and repair;
  • In line with current trends;
  • multi-language;
  • Embedded server Jetty;

Quarkus

  • Quick start
  • JAR is small, about 10M;
  • Very little documentation

Guess you like

Origin www.cnblogs.com/CQqfjy/p/12724119.html