Skip to content
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

DefaultRedisCacheWriter performance issue #2025

Closed
rickgong opened this issue Apr 2, 2021 · 1 comment
Closed

DefaultRedisCacheWriter performance issue #2025

rickgong opened this issue Apr 2, 2021 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@rickgong
Copy link

rickgong commented Apr 2, 2021

We've been bumped into Redis performance issue recently, due to too many REDIS KEYS commands were requested.
Thousands of KEYS commands were sent to Redis server, while our codes never use KEYS command directly.

My college found that KEYS command came from DefaultRedisCacheWriter.clean method.
byte[][] keys = Optional.ofNullable(connection.keys(pattern)).orElse(Collections.emptySet()) .toArray(new byte[0][]);

My question is: Is there an option to switch it to Redis SCAN method? Or I have to resort to a customized RedisCacheWriter?

A while loop of SCAN usually takes client more time to complete, so it is actually still a less-satisfactory solution. The advantage is SCAN method will not block REDIS server for long.

Cache clearing may be performed in an asynchronous fashion, while the DefaultRedisCacheWriter goes for synchronous way, it therefore blocks both client and Redis Server, with the advantage that subsequent lookups won’t be seeing the cache entries any more.

Version: spring-boot, 2.3.3, spring-data-redis, 2.3.3.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 2, 2021
@mp911de
Copy link
Member

mp911de commented Apr 7, 2021

This is basically a duplicate of #1721. A potential way out could be introducing a clean strategy that either uses KEYS or SCAN.

@mp911de mp911de closed this as completed Apr 7, 2021
@mp911de mp911de added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants