简体   繁体   中英

Spring Boot vs. Web server memory consumption

If I set into a web server (Tomcat, Undertow) an established memory consumption such as -Xms 1024m -Xmx 1024m, the JVM still can increase the memory consumption by factors of buffers, threads and native routines. That means 1024m will not the maximum memory used and I may see into SO a process running with much more than that.

With Spring Boot applications each jar will have your own web server so in this case if I do not set any -Xms / -Xmx in java execution it will get the default values from JVM in that SO

So, my doubt is if I have multiple Spring Boot applications running at the same server, shouldn't I have a bigger memory consumption than just having a single web server with several WAR's inside?

That memory question also applies to CPU and disk usage, does Spring Boot need more system resources to run?

It's not clear from your post if you are comparing Spring vs non-Spring application but I'll assume it's the case.

Spring does not have particular system resource requirements. In general when you run a Spring application in a container you can expect a (slightly) higher resource consumption because the framework loads more classes and does some processing that would have been avoided if you did not use Spring at all.

If you consider the Spring Boot case, you'll see that you can run a Spring Boot web application in two ways:

  1. via a standalone container
  2. package it as a WAR and run it in your container of choice

In the first case, if there is more than one application, you'll need more resources because there will be multiple containers running (one for each Spring Boot application). In the second case you'll need less because all the applications are consolidated in a single container. This last consideration is more a matter of how you deploy instead of an intrinsic property of Spring or Spring Boot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM