Can cluster slots be cached beyond request lifecycle? #2456
-
Hello,
Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I created a little toy script that connects to a constructor, echos a value and keeps track of how many times You can use php's built-in webserver with an undocumented env variable to watch as the slots get cached in each worker. # Start PHP's cli based webserver with 4 workers.
PHP_CLI_SERVER_WORKERS=4 php -S "localhost:9999" -t path/to/count-cluster-slots.php
# Then in another terminal. You can also use a browser if that's more convenient.
w3m "http://localhost:9999/count-cluster-slots.php?host=localhost&port=7000" -dump As you hit the URL you should see If it continues to call |
Beta Was this translation helpful? Give feedback.
-
Thank you for the test script. I ran it and indeed
Sometimes (like <20%) of the time it's not double, feeling like correct slot/node for random key is hit immediately. Other times (~80%) it's around double time taken, like it get MOVED response or something, but the slots are already cached judging by constructor time taken. |
Beta Was this translation helpful? Give feedback.
redis.clusters.cache_slots
usesPHP
'spersistent_list
mechanism, which survives multiple requests. It will live until we invalidate it (e.g. PhpRedis receives aMOVED
response from the cluster). It's important to note however, that each PHP-FPM worker will have it's own cache. So if you have 8 workers, they all need to warm up but at that point, you shouldn't see additional calls toCLUSTER SLOTS
.redis.pconnect.pooling_enabled
enables persistent connection pooling.RedisCluster
will use the pool if persistent connections are requested in the constructor..redis.clusters.persistent
is just used when connecting to "named" clusters which can be specified inphp.ini
. To my knowledge this fe…