I have a serverless redis-based Elasticache instance. I've configured Laravel to use redis as it's session driver and configured the pointed the redis connection at my Elasticache instance. I'm using PHPRedis as the driver.
When I look at the metrics for that cache, the "TotalCmdsCount" is significantly higher than expected. StringBasedCmds tracks very closely with the number of requests to my application, but TotalCmdsCount is consistently ~6x higher. This seems to be driven entirely by NonKeyTypeCmds. So my questions is what are all these extra commands? And what if anything can I do to reduce them
Serverless Elasticache doesn't support the "monitor" command so I can't easily profile the actual commands.
I would expect TotalCommands to be approximately 2 x TotalRequests, not 6x. (a get at the start of each request a set at the end of the request).
relevant .env settings
SESSION_DRIVER=redis
REDIS_HOST=<my-instance>.serverless.use1.cache.amazonaws.com
REDIS_PORT=6379
REDIS_PASSWORD=*****
REDIS_USERNAME=default
redis section of config/database.php
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', (env('APP_ENV') === 'local' ? gethostname().':' : '').'myapp:'),
'persistent' => true,
// Needed for TLS clustering to work!
'context' => []
],
'clusters' => [
// More undocumented behavior - if you actually need to connect with a password, you need to supply it as an option
// see PhpRedisConnector.php. I don't see a way to supply a non-default user name.
'options' => [
'password' => env('REDIS_PASSWORD'),
],
'default' => [
[
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
],
'cache' => [
[
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
],