redis icon indicating copy to clipboard operation
redis copied to clipboard

[QUESTION] How to increase Redis Cache Hit Ratio?

Open devjaythakkar opened this issue 1 year ago • 1 comments

Here are all the info stats "total_connections_received" => "329" "total_commands_processed" => "77333" "instantaneous_ops_per_sec" => "123" "total_net_input_bytes" => "12987896" "total_net_output_bytes" => "960654" "instantaneous_input_kbps" => "18.98" "instantaneous_output_kbps" => "0.60" "rejected_connections" => "0" "sync_full" => "0" "sync_partial_ok" => "0" "sync_partial_err" => "0" "expired_keys" => "17" "expired_stale_perc" => "0.06" "expired_time_cap_reached_count" => "0" "expire_cycle_cpu_milliseconds" => "25" "evicted_keys" => "0" "keyspace_hits" => "1748" "keyspace_misses" => "16554" "pubsub_channels" => "0" "pubsub_patterns" => "0" "latest_fork_usec" => "433" "migrate_cached_sockets" => "0" "slave_expires_tracked_keys" => "0" "active_defrag_hits" => "0" "active_defrag_misses" => "0" "active_defrag_key_hits" => "0" "active_defrag_key_misses" => "0" "tracking_total_keys" => "0" "tracking_total_items" => "0" "tracking_total_prefixes" => "0" "unexpected_error_replies" => "0" "total_reads_processed" => "55734" "total_writes_processed" => "55406" "io_threaded_reads_processed" => "0" "io_threaded_writes_processed" => "0"

PHP Version 8.0

Laravel Version 8.0

My config setup in Laravel 'redis' => [

    'client' => env('REDIS_CLIENT', 'predis'),

    'options' => [
        'cluster' => env('REDIS_CLUSTER', 'redis'),
        'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
        'scheme' => env('REDIS_SCHEME', 'tcp'),
    ],

    'default' => [
        'url' => env('REDIS_URL'),
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', '6379'),
        'database' => env('REDIS_DB', '0'),
        'scheme' => env('REDIS_SCHEME', 'tcp'),
        'path' => env('REDIS_PATH', ''),

    ],

    'cache' => [
        'url' => env('REDIS_URL'),
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', '6379'),
        'database' => env('REDIS_CACHE_DB', '1'),
        'scheme' => env('REDIS_SCHEME', 'tcp'),
        'path' => env('REDIS_PATH', ''),
    ],
],

I want to decrease the keyspace_misses and increase the keyspace_hits, I have tried many thing but not a single one work for me. Can anyone help me?

devjaythakkar avatar Nov 07 '23 06:11 devjaythakkar

Might be usecase specific since no keys were evicted "evicted_keys" => "0" and the keyspace misses just mean that there were roughly 16554 new keys created, and only 17 of them expired based on their TTL

AMX0013 avatar Apr 16 '24 05:04 AMX0013