If you want to start your app as quickly as possible (most people do) there are some tweaks you might consider. Here are some ideas:
- Use the
spring-context-indexer(link to docs). It’s not going to add much for small apps, but every little helps.
- Don’t use actuators if you can afford not to.
- Use Spring Boot 2.1 and Spring 5.1.
- Fix the location of the Spring Boot config file(s) with
spring.config.location(command line argument or System property etc.).
- Switch off JMX - you probably don’t need it in a container - with
- Run the JVM with
-noverify. Also consider
-XX:TieredStopAtLevel=1(that will slow down the JIT later at the expense of the saved startup time).
- Use the container memory hints for Java 8:
-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap. With Java 11 this is automatic by default.
Your app might not need a full CPU at runtime, but it will need multiple CPUs to start up as quickly as possible (at least 2, 4 are better). If you don’t mind a slower startup you could throttle the CPUs down below 4. If you are forced to start with less than 4 CPUs it might help to set
-Dspring.backgroundpreinitializer.ignore=truesince it prevents Spring Boot from creating a new thread that it probably won’t be able to use (this works with Spring Boot 2.1.0 and above).
Post a Comment
Note: Only a member of this blog may post a comment.