Skip to content

Performance degradation in Web layer after upgrade to Spring 6 #31098

Closed as not planned
@alexey-anufriev

Description

@alexey-anufriev

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:
image

And here is a request processing of the URL that has no path variables:
image

Memory

One more thing that was discovered is memory consumption, most of the allocations are happening here:
image

This is the size per minute
image


How can this be improved? One thought is around some kind of caching for PathParser to avoid extra calculations while request matching.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions