spring-framework: Performance degradation in Web layer after upgrade to Spring 6
Affects: 6.0.10 (Spring Boot 3.1.1)
Summary: After upgrade to Spring Boot 3.x application started to take more time for web requests processing.
Description:
Initially, the application was based on Spring Boot 2.7.14 (Java 17). But since we upgraded to Spring Boot 3.1.1 we noticed performance degradation in web layer. Requests processing took extra time in comparison with Boot 2.x. Upgrade to Spring Boot 3.1.2 made it ever worse. Tomcat’s MessageBytes serialization started to perform even slower. So we reverted to Spring Boot 3.1.1.
One more thing that was discovered in the profiler is slow performance of AntMatcher. So we followed the recommendation from upgrade guide of Spring Boot 2.6 and witched to PathParser. As it turns out, this did not make much of an improvement (see details below).
CPU
Here are some details captured using DataDog profiler.
Here is a request processing of the URL that has path variables:
And here is a request processing of the URL that has no path variables:
Memory
One more thing that was discovered is memory consumption, most of the allocations are happening here:
This is the size per minute
How can this be improved? One thought is around some kind of caching for PathParser to avoid extra calculations while request matching.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 39 (8 by maintainers)
https://github.com/spring-projects/spring-security/issues/14128 is now fixed and available in Spring Security 6.1.6-SNAPSHOT and 6.2.1-SNAPSHOT. Please test your applications with the current Spring Boot 3.2.1-SNAPSHOT version to check the performance changes. Release is scheduled next week for Spring Boot.
hi @goafabric,
yes, APM showed good metrics and latency went back to normal, so it was confirmed that the performance is good
It took a bit of time to validate the fix completely (also considering NY holidays), but we are done now, and I can confirm, that we not only got rid of performance degradation, but also got performance boost with path-parser vs ant-matcher.
@bclozel, and the rest of spring team, thank you for your effort and help!
Hi, @alexey-anufriev i just stumbled on this issue today … after discovering that a simple request in boot 3.25 with security will take 100ms while in boot 2.7 it’s only 5 ms.
So in one of your previous posts you mentioned that you could verify that it’s fixed? Because the increased reponse time is still there in 3.25 for me. (i am aware that you are not a member of the spring team …)
thanks in advance
@alexey-anufriev Awesome, thanks for letting us know!
@akhilbrao, actually 3.1.5