-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate startup performance between main and jar #7493
Comments
I've done some basic tests using these sample apps and none of the numbers checks out. For instance, config service starts under 4s for me and the reporter claims 16s. We need the exact apps and more details about how to reproduce this. |
FWIW I see virtually no difference between Spring Boot 1.3.8 and 1.4.2 with a plain vanilla Spring Boot + Actuator app (starts up in about 2s). Launching from a fat jar is marginally faster, but it's only about 30% for the benchmarks I ran so far. I'll publish some more when I have a complete picture. This is with local filesystem on a SSD. One observation that might be relevant: setting |
@wilkinsona requested a change in Tomcat to improve this by default, yes. |
They rejected my request. Apparently huge variance in startup time is the desired default behaviour. To overcome this, we use a custom session manager that only initializes the |
Roger that. It explains the difference that I saw between 1.4.2 and 1.3.8 anyway (but not the OP issue). |
Startup times of 2 to 4 seconds sound awesome. Is it my hardware? Should not make that huge of a difference, I have a Mac Book Pro 2013... I'll rerun my tests and give you more details about my setup. Will have to wait until the weekend, though. |
@berndgoetz this is what we need:
Thanks! |
Here's the example: https://github.com/berndgoetz/spring-boot-startup. I've included some details how I ran the application and some measurements in the README file. |
Your app is a bit like the Petclinic (Hibernate and Spring Data JPA), so I'd expect it to have similar characteristics. It starts for me in 5s (jar file) or under 4s (main method) on my Dell desktop, and on my old laptop (2011 vintage) it's 10s and 9s (surprisingly not much faster for the main method there). I know that @aclement has also found that his Mac runs things much faster from the exploded jar with the main method, but nothing ever ran as slow as yours did from the jar. Do you have something else in your environment (encypted disk, AV software or something)? Can you try these benchmarks on your box: https://github.com/dsyer/spring-boot-startup-bench? |
@snicoll the config server starts up on my Mac (2013) in about 4 seconds, yes. But when I start the same application as a jar, it bumps up to 15/16 seconds. I've created a new repository for it, just to be sure we're talking about the same thing: https://github.com/berndgoetz/config-service. I still get the same numbers, main class: 4 seconds, jar: 15 seconds. I continue collecting numbers, separately from this comment. @dsyer adding the security property to the startup as
added 2-3 seconds startup time (again, on my MacBook Pro from 2013) for me. |
I have collected a few more startup numbers today for the config service at https://github.com/berndgoetz/config-service.
Now to the reservation service at https://github.com/berndgoetz/spring-boot-startup. It connects to the local config service above on port 8888:
Comments/Findings:
Except if you want to look into the MacBook differences more closely, I think you can't do a lot about the whole thing here. Feel free to close this issue. I will most probably have some new follow-up investigations concerning even bigger differences in startup times when it comes to run a Spring Boot application in a Websphere Liberty container. |
Thanks for the update. Seems like your MacBook sucks. You could take the inexactness out of the tests by running the benchmarks as I suggested above already. How about doing that? |
I missed that one. Yes, I will do that, keep you posted. |
Ok, got it now - my MacBook Pro didn't suck, I just had a virus scanner running on it. After removing the virus scanner, I reran my reservation service as a jar file again, and it now starts up even slightly faster than the main method start, in below 7 seconds compared to the 40 seconds before. Crazy stuff. I can imagine that virus scanners have a lot of work to do when a process unfolds/unpacks/looks into a file with many files in it. This is a huge efficiency killer, I have to say. So for anybody coming here for slow Spring Boot startup times: It's your virus scanner, stupid! ;-) Here are the numbers, before and after: Host: snoopie, i7, 2.6GHz, 16 GB 1600 MHz DDR3, 500 GB SSD
After deactivating virus scanner:
@dsyer Thank you for your wonderful and great startup benchmark. You rock! |
Here's a top tip from @aclement
Without the flag:
|
Here's another MBP benchmark result (from Andy C): ac-rmbp, late-2013, i7, 2.6Ghz, 16gb RAM, SSD (717MB/s READ), JDK180_92
|
MacBook Pro (15-inch, 2016), 2.9 GHz Intel Core i7, 16 GB 2133 MHz LPDDR3:
|
Any updates on this issue? I am facing the same problem. Running the application as |
No updates. Check your system for antivirus and similar constraints. Read the discussion above. |
@dsyer We are using spring boot for local, staging and prod environment. Staging and prod are AWS EC2 instances having Ubuntu as their OS. I don't think so it is an antivirus issue as the issue is reproable on almost everyone's Mac and Linux machine in the team. I would really appreciate if you can mention what other similar constraints might be leading to much a performance dip.
The trace logs in both the cases are full of "Looking for matching resources in jar file" somehow indicating that component scan is taking a lot of time. The |
I guess you don't have to use the "java -jar" form if it costs you so much. Really you are just paying the cost of unzipping all your jar files. You could measure that to get an idea I suppose. I don't have any idea why it is so expensive in your case, but disk I/O is very expensive, and your EC2 instances are probably paying heavily for it. You could try changing the storage. Or unpack the app when you build the EC2 image. |
A fat jar shouldn't add any unzipping cost for jar files in |
@sahilnagpal I'm curious what steps did you take in benchmarking the start up? I looked into @dsyer repo here, which is pretty cool, but the method for applying that to external projects is neither documented, nor very clear to me yet (dsyer/spring-boot-startup-bench#7). |
btw. We have seen huge improvements of startup time by using |
We've done quite a bit of work on the jar launcher since this issue was raised (such as #11207). Since most of the figures in this issue are now outdated I'm going to close this one and we can take any new performance issues as they come. |
See spring-projects/spring-framework#19523
The text was updated successfully, but these errors were encountered: