Fully featured low overhead profiler for Java EE and Java SE platforms.
Easy to use performance and memory .NET profiler for Windows and Linux.
Performance monitoring and profiling of Jenkins, Bamboo, TeamCity, Gradle, Maven, Ant and JUnit.

Spring Boot application takes too long to initialize with th

Moderators: Vladimir Kondratyev, Anton Katilin

Spring Boot application takes too long to initialize with th

Postby maseev » Mon Jul 23, 2018 7:26 pm

Hi.

I've got a Spring Boot application which I run inside a Docker container. The problem is, it takes too long for the application to fully initialize.

For example, when I run the application inside the Docker container without the YourKit Java agent attached to it, it takes approximately 1 minute to initialize and start accepting requests from users.
However, when I run the very same application with the YourKit Java agent attached to it, it takes 10 minutes to start. This particular problem manifests itself only in the container environment.

I used the YourKit guide in order to setup the Java agent inside a Docker container, but it seems to me there's something else going on. Unfortunately, I wasn't able to see any problems in the agent log. It looks pretty normal to me.

Is there anything I can do to find out what slows down the application with the agent attached to it?

Thanks.
maseev
 
Posts: 4
Joined: Sat Jul 21, 2018 4:43 pm

Re: Spring Boot application takes too long to initialize wit

Postby maseev » Tue Jul 24, 2018 3:15 am

maseev
 
Posts: 4
Joined: Sat Jul 21, 2018 4:43 pm

Re: Spring Boot application takes too long to initialize wit

Postby Anton Katilin » Tue Jul 24, 2018 6:23 am

Hi,

There is nothing odd in the log.

Please note you run with the debugger too (-agentlib:jdwp). Please check if the problem is reproducible without -agentlib:jdwp.

Please try the agent startup options recommended by the EE server integration wizard:

-agentpath:<path to agent>=port=<port>,listen=all,disablestacktelemetry,exceptions=disable

Does this help?

Best regards,
Anton
Anton Katilin
 
Posts: 6064
Joined: Wed Aug 11, 2004 8:37 am

Re: Spring Boot application takes too long to initialize wit

Postby maseev » Thu Jul 26, 2018 5:18 pm

Anton Katilin wrote:Hi,
Please note you run with the debugger too (-agentlib:jdwp). Please check if the problem is reproducible without -agentlib:jdwp.


Yes, it's reproducible without the remote debugger agent attached to the JVM. The interesting thing is when I leave the jdwp agent connected to the JVM and add the "disablestacktelemetry,exceptions=disable" options to the YourKit Java agent, the startup time drops from 10 minutes to 2.
If I remove the jdwp agent and leave only the YourKit Java agent with these options "disablestacktelemetry,exceptions=disable" the application takes only 1 minute to start.

Anton Katilin wrote:Please try the agent startup options recommended by the EE server integration wizard:

-agentpath:<path to agent>=port=<port>,listen=all,disablestacktelemetry,exceptions=disable

Does this help?


Actually, yes, it does help. Now the application takes a little bit more than a minute to fully initialize (without jdwp agent though).

Although, I'm a little bit worried whether it's a good idea to disable stack telemetry altogether. The documentation says that this information can potentially be very useful in the debugging process. If I understand correctly, I won't be able to turn this feature back on using YourKit profiler.

And what about this option - "exceptions=disable"? Can I use "exceptions=off" instead of "disable" so I'd be able to turn this feature on at runtime via YourKit profiler connected to the app? I'm not really sure that's a good idea to disable this feature completely.
maseev
 
Posts: 4
Joined: Sat Jul 21, 2018 4:43 pm

Re: Spring Boot application takes too long to initialize wit

Postby Anton Katilin » Thu Jul 26, 2018 6:32 pm

Hi,

I won't be able to turn this feature back on using YourKit profiler.

It's not true. You can turn stack telemetry on and off in runtime when you want, with the toolbar button in the profiler UI or programmatically:
https://www.yourkit.com/docs/java/help/threads.jsp

And what about this option - "exceptions=disable"? Can I use "exceptions=off" instead of "disable" so I'd be able to turn this feature on at runtime via YourKit profiler connected to the app? I'm not really sure that's a good idea to disable this feature completely.

Please try "exceptions=off". Normally, the overhead should not be significant.

Best regards,
Anton
Anton Katilin
 
Posts: 6064
Joined: Wed Aug 11, 2004 8:37 am

Re: Spring Boot application takes too long to initialize wit

Postby maseev » Fri Jul 27, 2018 2:41 am

Anton Katilin wrote:It's not true. You can turn stack telemetry on and off in runtime when you want, with the toolbar button in the profiler UI or programmatically:
https://www.yourkit.com/docs/java/help/threads.jsp


Oh, I see. I forgot about this button completely. Well, that's great. I guess it's not a big deal to have stack telemetry disabled from the start because I can always turn it back on from YourKit profiler. The only thing is that I won't have any "historical" data about stack telemetry unless I enable this feature from profiler by clicking on that button you mentioned before.

Anton Katilin wrote:Please try "exceptions=off". Normally, the overhead should not be significant.


Sure, I already did. It works perfectly.

Thank you for your help, Anton.

Have a great day.
maseev
 
Posts: 4
Joined: Sat Jul 21, 2018 4:43 pm

Re: Spring Boot application takes too long to initialize wit

Postby sv123455 » Mon Aug 09, 2021 10:37 pm

We have a similar setup, a spring boot app,. running within docker, and like most spring apps, quite a bit of runtime code generation goes on.

When we start the app without the yourkit - 30-35 seconds of startup time
When we start the app with yourkit and these parameters : disablestacktelemetry,exceptions=disable - the startup time is about 40-45 seconds
When we start the app with yourkit and these parameters : disablestacktelemetry,exceptions=off - the startup time is about 210 seconds

and needless to say - without any explicit parameters to disablestacktelemetry and exceptions it takes much longer than the 210 seconds,. closer to 300+ seconds

Any thoughts on why we are seeing that much of a difference between exceptions=off vs exceptions=disable?

Do let me know if you need any other info,

regards,
sv123455
 
Posts: 1
Joined: Mon Aug 09, 2021 10:25 pm

Re: Spring Boot application takes too long to initialize wit

Postby Anton Katilin » Tue Aug 10, 2021 6:09 am

Exception profiling depends on exception events in the JVM.
https://www.yourkit.com/docs/java/help/ ... filing.jsp

"exceptions=off" enables exception events in the JVM but does not immediately start the exception profiling that can instead be started later in runtime.

"exceptions=disable" fully disables exception events in the JVM to totally eliminate corresponding overhead. The exception profiling will not be available.

Apparently the number of throws exceptions in your case is high which makes the event overhead significant.
Anton Katilin
 
Posts: 6064
Joined: Wed Aug 11, 2004 8:37 am


Return to Java Profiler

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron

YourKit uses cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By browsing our website, you consent to our use of cookies and other tracking technologies in accordance with the Privacy Policy.