Search code examples
springspring-bootspring-boot-starter

Do Spring Boot starter packages impact performance?


Can gradle starter packages for spring boot, such as

org.springframework.boot:spring-boot-starter-web
org.springframework.boot:spring-boot-starter-cache

introduce any significant latency (>2ms api response time) as opposed to non-starter, specific packages? Would it have any significant improvement of performance to be explicit and specific with dependency deceleration?

Another relevant question, suppose a starter package included a package/dependency I did not use/implement in the service (directly or indirectly), does that package get loaded or have any impact on the performance of the service?


Solution

  • introduce any significant latency (>2ms api response time) as opposed to non-starter, specific packages?

    Pulling in packages in general can introduce arbitrary stuff at runtime, and arbitrarily change response times. This is true for starter packages vs. non. Starter packages are typically designed to "wire things in" to your application context so they are more likely to. That being said, spring boot is designed to be production-ready so released spring-provided starter packages (as opposed to SNAPSHOT builds or stuff from some random github repo) are, in my experience, reliable.

    Would it have any significant improvement of performance to be explicit and specific with dependency deceleration?

    Maybe, but I would deem this unlikely. I'm strongly of the opinion that taking on dev complexity to solve performance is not the most efficient way, it's much cheaper to buy more/bigger hardware. There's a lot of analysis to back this up (google "premature optimization").

    Another relevant question, suppose a starter package included a package/dependency I did not use/implement in the service (directly or indirectly), does that package get loaded or have any impact on the performance of the service?

    Class loading in java is a somewhat involved topic. Here's a decent article. https://zeroturnaround.com/rebellabs/rebel-labs-tutorial-do-you-really-get-classloaders/2/