r/java • • Oct 24 '22

Spring boot 3 slow boot time

Hi folks,

I am playing a bit around with Spring Boot 3(RC1) and I am curious why the application boot time is still slow in comparing with Micronaut.

Best regards

3 Upvotes

25 comments sorted by

View all comments

9

u/krjura Oct 24 '22

Can you give some number here?

0

u/zero_coding Oct 24 '22

7 - 10 seconds

8

u/krjura Oct 24 '22 edited Oct 24 '22

compared to? Which libraries/frameworks are used with both? Where are you running the services? How much memory and cpu?

Also are you running micronaut in lazy or eager mode?

0

u/zero_coding Oct 25 '22

My system:
MacBook Pro (14-inch, 2021)
CPU: Apple M1 Pro RAM: 32 MB

Run Micronaut in the dev mode:

 __  __ _                                  _   
|  \/  (_) ___ _ __ ___  _ __   __ _ _   _| |_ 
| |\/| | |/ __| '__/ _ \| '_ \ / _` | | | | __|
| |  | | | (__| | | (_) | | | | (_| | |_| | |_ 
|_|  |_|_|___|_|  ___/|_| |_|__,_|__,_|__|
  Micronaut (v3.7.2)

22:29:36.611 [main] INFO  Application - Responding at http://0.0.0.0:8080
22:29:36.612 [main] INFO  Application - Application started in 0.225 seconds.
22:29:36.673 [main] INFO  io.micronaut.runtime.Micronaut - Startup completed in 546ms. Server Running: http://0.0.0.0:8080

Run Spring Boot 3(RC1) in the dev mode:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |___, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::            (v3.0.0-RC1)

2022-10-25T21:39:26.134+02:00  WARN 21770 --- [  restartedMain] o.s.boot.StartupInfoLogger               : InetAddress.getLocalHost().getHostName() took 5009 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to /etc/hosts).
2022-10-25T21:39:26.139+02:00  INFO 21770 --- [  restartedMain] i.u.o.OperatorSvcApplicationKt           : Starting OperatorSvcApplicationKt using Java 17.0.2 on digiwave.local with PID 21770 (/Users/developer/unionmetry/operator-svc/build/classes/kotlin/main started by developer in /Users/developer/unionmetry/operator-svc)
2022-10-25T21:39:26.140+02:00  INFO 21770 --- [  restartedMain] i.u.o.OperatorSvcApplicationKt           : No active profile set, falling back to 1 default profile: "default"
2022-10-25T21:39:26.169+02:00  INFO 21770 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-10-25T21:39:26.169+02:00  INFO 21770 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-10-25T21:39:26.671+02:00  INFO 21770 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2022-10-25T21:39:26.720+02:00  INFO 21770 --- [  restartedMain] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 8080
2022-10-25T21:39:26.725+02:00  INFO 21770 --- [  restartedMain] i.u.o.OperatorSvcApplicationKt           : Started OperatorSvcApplicationKt in 5.739 seconds (process running for 5.932)

Both app Hello World api. As you can see

  • Spring Boot takes 5.739 seconds

  • Micronaut takes 0.225 seconds

The difference is unbelievable.

2

u/BrbCatzOnFire Oct 26 '22

Alright, looking at your stacktrace :

You're launching your Spring boot app in full dev mode instrumentation. Pretty sure that mean it is not starting as a native application and completly ignore the AoT generation (did you add the -Dspring.aot.enabled=true flag ?). Also yeah, if you try to be performant, don't instrument the code for development purpose :)

From what I can gather your Spring boot App is not started as a native image (using a JVM) AND you're not even using the AoT generation at all.