spring-projects / spring-projects/spring-session
Performance improvement for RedisSessionRepository
@marcusdacoregio is already working on this.
Since Aug 6, 2024.
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 1.2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 55
Description
Describe the bug
First of all, it's not a bug. It's a possibility to improve performance by avoiding unnecessary deserialization in RedisOperations every time session is loaded from redis. In current implementation of RedisSessionRepository it is expected that RedisOperations converts byte arrays to objects which then are stored in MapSession and it's done for all attributes on every session load. Instead, this deserialization can be postponed and MapSession will store Supplier object the same way as it's done in JdbcIndexedSessionRepository. Same improvement can be applied to RedisIndexedSessionRepository.
To Reproduce
- Use RedisSessionRepository(real application pages or test)
- Make session attribute serialization/deserialization heavier - for instance, enable encryption - this will help to show the difference.
- Create 2 application pages(in test it can be just different set of attributes). The first one with bigger number of attributes(and bigger data), the second with, say, single small attribute.
- Compare latency of second page between original RedisSessionRepository and postponed deserialization in the next scenario:
- Create a new session
- Call the first page to populate all session attributes.
- Call the second page.
Expected behavior
Implementation with postponed deserialization should provide better performance.
Sample
A link to a GitHub repository with a minimal, reproducible sample.
Reports that include a sample will take priority over reports that do not.
At times, we may require a sample, so it is good to try and include a sample up front.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.