-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Serving static files slowdown [SPR-16654] #21195
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
Comments
Rossen Stoyanchev commented I cannot confirm with the behavior with the spring-mvc-showcase which gives 20-80 ms per resource. Is this reproducible in a basic sample? What server are you using? How's resource handling configured? Does it matter if Boot is used or not, or if the app is deployed as a war? |
Ivan Martos commented In basic example I cant reproduce problem. However I can provide code in which the error is reproducable |
Rossen Stoyanchev commented The switch from 1.5.9 to 2.0.0 does not narrow it down. That's more than a year's worth of work on the Boot side, even more so on the Spring Framework side. Also I can't see where resources are served from (file system, classpath, ServletContext, other) when you experience the slowdown? Since you've got the reproducible scenario , can you run a request through a profiler like Yourkit or VisualVM ? |
Ivan Martos commented sources are served from file system |
Rossen Stoyanchev commented Anything further? |
Ivan Martos commented I'll provide profiling result tomorrow |
Ivan Martos commented Ok, got the profiling results If there is anything further you need from me just let me know |
Rossen Stoyanchev commented Thanks for the profiling results. The main thing I was looking for is a call tree with total time spent. For that I looked in new-spring-cpu.nps and this is what I found:
It's a little hard still to make hard conclusions but it looks this may be related to BCrypt. That would apply more widely but maybe it is easier to spot as an outlier with static resource. So for next steps, try without BCrypt, perhaps using the standard password encoder that doesn't slow down to confirm if that makes a difference. If it doesn't, take another snapshot to see what methods bubble up this time without BCrypt, and it would also help a lot to trace only in org.springframework related classes to avoid the heavy skewing from Tomcat's TaskQueue.
|
Ivan Martos commented Hi. I wasn't using any bcrypt password, my passwords were in format of "{noop}xxxxxxxx". @Bean
open fun passwordEncoder(): NoOpPasswordEncoder {
return NoOpPasswordEncoder.getInstance() as NoOpPasswordEncoder
} Reponse times for images are back at around 100ms. So this works. My hard guess is that something is wrong in DelegatingPasswordEncoder However now I have a warning about using deprecated NoOpPasswordEncoder |
Rossen Stoyanchev commented Okay so it looks like this is related to Spring Security. Rob Winch any comments, or would you suggest to create a ticket under Spring Security? |
Rob Winch commented
You may have since changed it, but the results in the profiler indicate that BCrypt was being used at the time of profiling. As Rossen mentions, this is intentionally slow. Can you try profiling again without BCrypt enabled? |
Rossen Stoyanchev commented We might as well separate things a bit at this point into two possible issues.
As for 1) it might be best to open a separate ticket under Spring Security and describe how you're securing static resources, what you expect, and what you found. |
Rossen Stoyanchev commented IvanM any further comments? |
Ivan Martos commented yeah, sorry for the delay Here are sampling results without bcrypt and with editions mentioned above. Sampling is only for org.springframework package. Current code can be found at (branch develop) currently lower boundary is about 60ms and upper about 220ms. After bypassing BCrypt issue, everything works fine. It seems that the problem is related only to BCrypt. If there is anything more you need from me just let me know. Or should I rather create separate ticket under Spring Security? Thanks |
Rob Winch commented Thanks for the follow up IvanM
If you are only seeing slowness when using BCrypt, then there is nothing to report. As Rossen mentioned, BCrypt is intentionally resource intensive and thus is deliberately slow. To get better performance you should expect to exchange the long term credential (a username / password) for a short term credential (i.e. a session or a short lived OAuth Token). |
Rossen Stoyanchev commented I'm resolving since clearly there is nothing to fix in the Spring Framework. Feel free to comment further for clarification. |
Possible root cause: spring-projects/spring-security#8498 |
Ivan Martos opened SPR-16654 and commented
After we upgraded our project to Spring Boot 2.0.0.RELEASE (that comes with spring-webmc-5.0.4.RELEASE), we experienced major slowdown for serving static files using
When we were using Spring Boot 1.5.9.RELEASE average response time for images was about 40ms. After the upgrade it has risen up to average 1400ms.
Code is the same, only thing that changed was spring boot version (with modifications required for update to newer version of spring boot).
After we reverted back to Spring boot 1.5.9 (with spring-webmc-4.3.13.RELEASE) serving static files was once again very fast.
I'm attaching access logs with response times.
Affects: 5.0.4
Attachments:
0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: