When running a spring boot webapp in docker, should I use the "-server" java flag?

Viewed 157

I was reading about escape analysis with java and the recommendation is to run java using the -server flag. Is this a best practice when running a spring boot application in docker?

UPDATE I'm currently using java 8 but hope to be on java 11 by the end of the year

1 Answers

If your java version is 64-Bit then the -server is implicit (see Oracle docs)

-server

Selects the Java HotSpot Server VM. The 64-bit version of the JDK supports only the Server VM, so in that case the option is implicit.

The escape analysis is supported only by the Java HotSpot Server and it is enabled by default

-XX:+DoEscapeAnalysis

Enables the use of escape analysis. This option is enabled by default. To disable the use of escape analysis, specify -XX:-DoEscapeAnalysis. Only the Java HotSpot Server VM supports this option.

If no option specified (either client or server) the Java launcher detects if it runs on a "server-class" machine according to this table.

On a machine that it's not "server-class" (32-Bit) I would run Spring Boot with the -server option. The -client option is for GUIs.

Not sure if that answers your question but I hope it helps.

Related