티스토리 뷰

어떻게 하면 Springboot을 조금 더 빠릿빠릿하게 만들 수 있을까 찾아보았다. 지금 사용하고 있는 최신버전(2.5.4)도 만족스럽게 사용하고 있지만 찾아보면 자료가 있을것 같았다. 마침 좋은 자료가 있어서 공유하고자 한다. 

이것저것 해보고 현실적이고 괜찮다고 느낀건 빨간색으로 표시를 해 놓았다. 


How do I make my app go faster?

You are mostly going to have to drop features, so not all of these suggestions will be possible for all apps. Some are not so painful, and actually pretty natural in a container, e.g. if you are building a docker image it’s better to unpack the jar and put application classes in a different filesystem layer anyway.

  • Classpath exclusions from Spring Boot web starters:
    • Hibernate Validator
    • Jackson (but Spring Boot actuators depend on it). Use Gson if you need JSON rendering (only works with MVC out of the box).
    • Logback: use slf4j-jdk14 instead
  • Use the spring-context-indexer. It’s not going to add much, but Spring Boot autoconfiguration is indexed, and every little helps.
  • Before Boot 2.2, don’t use actuators if you can afford not to.
  • Use Spring Boot 2.1 and Spring 5.1 when they are available.
  • Fix the location of the Spring Boot config file(s) with spring.config.location (command line argument or System property etc.). Example for testing in IDE: spring.config.location=file:./src/main/resources/application.properties.
  • Before Boot 2.2, switch off JMX if you don’t need it with spring.jmx.enabled=false
  • Make bean definitions lazy by default. In Spring Boot use spring.main.lazy-initialization=true. Spring Boot 2.1 also has spring.data.jpa.repositories.bootstrap-mode=lazy.
  • Unpack the fat jar and run with an explicit classpath.
  • 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).

A more extreme choice is to re-write all your application configuration using functional bean definitions. This includes all the Spring Boot autoconfiguration you are using, most of which can be re-used, but it’s still manual work to identify which classes to use and register all the bean definitions. If you try this approach you might see a further 10% improvement in startup time (or more if you don’t use the lazy flags but that’s not related top the functional beans). Look at the BuncApplication to see how to start Spring Boot without the @Configuration class processor.

Excluding netty-transport-native-epoll also boosts the functional bean apps by about 30ms (but not noticeably the non-functional ones), so maybe a few percent.

출처 : https://github.com/dsyer/spring-boot-allocations

 

이 글에 대해 친절하게 하나하나 테스트를 한 위인이 있었다

 

Let's make SpringBoot app start faster

"How Fast is Spring?" is a session at Spring One Platform 2018. I watched the video and tr...

dev.to

이 위인님이 한 결과에 따르면 가장 효과가 좋고 간단하게 적용 가능한것은 

Run the JVM with -noverify. Also consider -XX:TieredStopAtLevel=1

이게 아닐까 싶다. 모든 항목을 적용하면 티끌모아 태산처럼 엄청나게 빨라진것도 확인할 수 있다. 

 

가능한 모든 방법을 써서 속도를 줄여보도록 하자. 

 

끝!

댓글
최근에 올라온 글
최근에 달린 댓글
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31