souin icon indicating copy to clipboard operation
souin copied to clipboard

Huge number of SCAN commands sent to REDIS

Open germanftorres opened this issue 3 months ago • 4 comments

Hi,

I'm using caddy + souin plugin + go-redis storage as reverse proxy to an imgproxy service.

extract from Dockerfile

FROM caddy:2.10.2-builder-alpine

xcaddy build \
    --with github.com/darkweak/souin/plugins/caddy \
    --with github.com/darkweak/storages/go-redis/caddy

Caddyfile

{
	auto_https off

	cache {
		redis {
			configuration {
				Addrs {$REDIS_ADDRR}
				Username {$REDIS_USERNAME}
				Password {$REDIS_PASSWORD}
				PoolSize 50
				ClientName souin-redis
			}
		}
	}
}

:8081 {
	cache {

		ttl 86400s

		allowed_http_verbs GET

		mode bypass_request
	}
	reverse_proxy :8080
}

I'm using Fly.io's managed redis service (Upstash redis) and in the service console I can see a huge amount of SCAN commands that are being sent to the instance from the region where my app is hosted.

Image

I was wondering if somehow the souin plugin is polling all the keys (via MapKeys or ListKeys) continuosly and if it's reasonably that the caching solution is issuing so many SCAN commands in comparison with the other commands (GET, SET) that seem to be ok with the little traffic I'm sending to a test server.

Thanks

Germán

PS: There's an issue documented at Flyio.s troubleshooting docs about Unexpected Increase in Command Count to REDIS from their own console display and monitoring purposes, but doesn't seem related as the increase is very modest in comparison to this issue.

germanftorres avatar Oct 08 '25 11:10 germanftorres

Hey @germanftorres I'm working on a way to reduce the number of mapping eviction and use another thing than the SCAN command.

darkweak avatar Oct 09 '25 09:10 darkweak

hi @darkweak. we are seeing the same problem in production. It appears this wasnt the case until recently. Can you tell us which commit introduced this? We would like to roll back ;)

EDIT: I think we found it: https://github.com/darkweak/souin/commit/bd94dfc0ce71ab063281aac4fa999faa57c72410

cdaguerre avatar Oct 23 '25 13:10 cdaguerre

I think that's the registering mapping eviction and run every minutes to purge IDX_ keys.

darkweak avatar Oct 23 '25 20:10 darkweak

Hey @darkweak, is there anything we can do to help?

cdaguerre avatar Nov 12 '25 14:11 cdaguerre