3

I inherited a SpringBoot application that was originally run with Spring boot 1.3 (embedded Tomcat) starting up the application using the java -jar project.war command.

Since we've upgraded to Spring boot 1.4, we've noticed that it is much slower to startup and has greater latency when searching as compared with when we run the application within our IDE (Both Eclipse and IntelliJ).

A good example is doing a search for "SMITH". When we run the app within our IDE, the search takes roughly 5-6 seconds. Using the exact same codebase, embedded server configuration, and host machine - a search on "SMITH"- when started using java -jar project.war, takes 14 seconds.

We've profiled the application up, down and backwards and still cannot figure out why it runs that much quicker within our IDE.

To get around the issues described above, we have to do the following:

  1. Exploding the war to a temp directory
  2. cd to WEB-INF directory
  3. run java -classpath "lib\:classes\:lib\*.jar" my.package.Main

Why is there such a big difference in those two command line features? Does providing a classpath to Java truly boost the performance that much?

========================================================================= EDIT: I've filed https://github.com/spring-projects/spring-boot/issues/8046 with Spring, which is basically a cut and paste from here

EDIT 2: If you've run into this issue and can share your code, please do so with Spring (Use the link above); My company has their environment locked down.

Dan
  • 979
  • 1
  • 8
  • 29
  • Let me just find some sources, but intuitively, I would believe it probably has something to do with the way the classpath is loaded. I know when I was a C# dev, we used to manually go through and touch the assemblies to get them preloaded before the app came up because there was very noticeable lag when you first loaded a feature otherwise. Do you get the same lag if you run the same search twice when running from the .war file? – HeadBangingSloth Jan 19 '17 at 23:16
  • @HeadBangingSloth, we have a caching framework in place that would prevent that lag. If we removed that framework then yes, the lag would still remain. I agree though, it has to be some sort of a classpath issue. – Dan Jan 23 '17 at 20:17
  • It's impossible for us to determine what's going on, and it's unlikely that it'd be simple for us to come up with an example project that exemplifies your exact performance issues. I would ***strongly encourage*** you to talk with your supervisor to convince them that this bug may be in the framework you're relying on to deliver an enterprise solution on, and that the maintainers need *some* project that can reproduce the symptoms you're seeing for this to get resolved. – Makoto Jan 23 '17 at 20:28
  • That aside, you mentioned you profiled it. Did you profile this between IDE and server? Did you run the profiler on the server directly? Perhaps those profile snapshots would be useful to see (on Spring's side); if a lot of the calls and time taken up lives in Spring code, they may have a better hook into figuring out what's going on. – Makoto Jan 23 '17 at 20:29
  • @Makoto - Yes, we profiled our local machines and the Servers the application was running on. There was no distinguishing factors between the two environments that could help us. I've let my management know about the possible Framework issue, however I doubt they'll provide a means to let it leave their intranet. They're happy enough with the work-around we came up with... – Dan Jan 23 '17 at 20:39

1 Answers1

0

Found this issue on Spring's github. Looks like a packaged archive will always be slower (I suspect because it needs to explode the archive before running it), but a WAR archive is expected to define a document root, whereas a JAR is not and that pretty much accounts for the performance difference. There is also this StackOverflow question about the difference between JAR and WAR, which also contains links which seem to support this.

Not 100% sure if this is the answer, but hopefully it at the very least puts someone else on the right track

Community
  • 1
  • 1
  • 1
    That is about startup time not runtime. The question is about runtime performance. – M. Deinum Jan 20 '17 at 06:52
  • I think I agree with the Spring guys then, without actual code it's a bit difficult to diagnose. They have a gitter channel as well, you might get some quicker feedback there – HeadBangingSloth Jan 21 '17 at 07:32
  • @HeadBangingSloth - I wish I could copy our code from my corporate AWS, however that's a no-no. Unfort. I dont have time to create a project to show them the issue. I guess it'll have to stay open or get updated when someone else runs into the issue. – Dan Jan 23 '17 at 20:19