How to Check Redis Cache Hit Ratio on Linux Server

Step-by-step guide to check Redis cache hit ratio. Monitor cache performance, track hit vs miss rates, and optimize cache configuration for better performance.

Last updated: 2026-01-11

How to Check Redis Cache Hit Ratio on Linux Server

Monitor Redis cache hit ratio to track cache performance, identify optimization opportunities, and ensure efficient cache utilization. This guide shows you how to check cache hit ratio and set up automated monitoring.

For comprehensive cache monitoring, see Cache Performance Monitoring. For troubleshooting cache issues, see Cache Miss Rate High Performance Impact.

Why Checking Cache Hit Ratio Matters

Cache hit ratio indicates how effectively your cache is working. High hit ratios mean most requests are served from cache, reducing database load and improving performance. Low hit ratios indicate cache optimization opportunities.

Method 1: Check Cache Hit Ratio with redis-cli

Get Cache Statistics

# Connect to Redis
redis-cli

# Get cache statistics
INFO stats

# Get keyspace hits and misses
INFO stats | grep keyspace_hits
INFO stats | grep keyspace_misses

# Calculate hit ratio
redis-cli INFO stats | grep -E "keyspace_hits|keyspace_misses"

Calculate Hit Ratio

# Get hits and misses
HITS=$(redis-cli INFO stats | grep keyspace_hits | cut -d: -f2 | tr -d '\r')
MISSES=$(redis-cli INFO stats | grep keyspace_misses | cut -d: -f2 | tr -d '\r')

# Calculate hit ratio percentage
if [ "$HITS" -gt 0 ] || [ "$MISSES" -gt 0 ]; then
  TOTAL=$((HITS + MISSES))
  RATIO=$(echo "scale=2; $HITS * 100 / $TOTAL" | bc)
  echo "Cache Hit Ratio: $RATIO%"
else
  echo "No cache activity yet"
fi

Method 2: Monitor Cache Performance

Track Hit Ratio Over Time

# Monitor hit ratio continuously
while true; do
  HITS=$(redis-cli INFO stats | grep keyspace_hits | cut -d: -f2 | tr -d '\r')
  MISSES=$(redis-cli INFO stats | grep keyspace_misses | cut -d: -f2 | tr -d '\r')
  if [ "$HITS" -gt 0 ] || [ "$MISSES" -gt 0 ]; then
    TOTAL=$((HITS + MISSES))
    RATIO=$(echo "scale=2; $HITS * 100 / $TOTAL" | bc)
    echo "$(date): Hit Ratio: $RATIO%"
  fi
  sleep 60
done

Method 3: Automated Cache Hit Ratio Monitoring with Zuzia.app

Set up automated monitoring to track cache hit ratio continuously and receive alerts when hit ratio drops below thresholds.

Step 1: Add Cache Hit Ratio Monitoring Command

  1. Log in to Zuzia.app Dashboard

    • Access your Zuzia.app account
    • Navigate to your server
    • Click "Add Scheduled Task"
  2. Configure Hit Ratio Check Command

    HITS=$(redis-cli INFO stats | grep keyspace_hits | cut -d: -f2 | tr -d '\r')
    MISSES=$(redis-cli INFO stats | grep keyspace_misses | cut -d: -f2 | tr -d '\r')
    if [ "$HITS" -gt 0 ] || [ "$MISSES" -gt 0 ]; then
      TOTAL=$((HITS + MISSES))
      echo "scale=2; $HITS * 100 / $TOTAL" | bc
    else
      echo "0"
    fi
    
    • Set execution frequency (every 5-10 minutes)
    • Configure alerts when hit ratio < threshold

Step 2: Configure Alert Thresholds

  • Warning: Hit ratio < 80%
  • Critical: Hit ratio < 60%
  • Emergency: Hit ratio < 40%

Step 3: Monitor Cache Memory Usage

Add command to monitor cache memory:

# Check Redis memory usage
redis-cli INFO memory | grep used_memory_human

Best Practices for Cache Hit Ratio Monitoring

1. Monitor Hit Ratio Continuously

  • Track hit ratio regularly
  • Alert when hit ratio drops below thresholds
  • Monitor hit ratio trends over time
  • Optimize cache configuration based on data

2. Optimize Cache Configuration

  • Adjust cache expiration policies
  • Optimize cache key strategies
  • Implement cache warming
  • Review cache invalidation patterns
  • Review hit ratio trends weekly
  • Identify performance patterns
  • Optimize cache configuration based on trends
  • Correlate cache performance with application changes

4. Set Appropriate Thresholds

  • Set thresholds based on application requirements
  • Adjust thresholds for different cache types
  • Monitor hit ratio percentiles
  • Alert on hit ratio degradation

Troubleshooting Low Cache Hit Ratio

Step 1: Identify Cache Issues

When cache hit ratio is low:

# Check current hit ratio
HITS=$(redis-cli INFO stats | grep keyspace_hits | cut -d: -f2 | tr -d '\r')
MISSES=$(redis-cli INFO stats | grep keyspace_misses | cut -d: -f2 | tr -d '\r')
# Calculate and display ratio...

# Check cache memory usage
redis-cli INFO memory

# Check cache key count
redis-cli DBSIZE

Step 2: Optimize Cache Performance

Based on investigation:

  1. Improve Cache Hit Ratio:

    • Optimize cache key strategies
    • Adjust expiration policies
    • Implement cache warming
    • Review cache invalidation
  2. Optimize Cache Memory:

    • Adjust memory limits
    • Optimize cache data structures
    • Implement memory-efficient caching
    • Scale cache infrastructure

FAQ: Common Questions About Cache Hit Ratio

What is a good cache hit ratio?

Good cache hit ratio depends on your application. Generally, hit ratios above 80% are excellent, 60-80% are good, 40-60% are acceptable, and below 40% indicate optimization opportunities.

How often should I check cache hit ratio?

For production caches, continuous automated monitoring is essential. Zuzia.app can check cache hit ratio every few minutes, storing historical data and alerting you when hit ratio drops below thresholds.

How do I improve cache hit ratio?

Improve cache hit ratio by optimizing cache key strategies, adjusting expiration policies, implementing cache warming, reviewing cache invalidation patterns, and ensuring frequently accessed data is cached.

Can cache monitoring impact cache performance?

Cache monitoring commands have minimal impact on cache performance when done correctly. Use appropriate monitoring frequency and avoid monitoring during peak cache usage periods.

Note: The content above is part of our brainstorming and planning process. Not all described features are yet available in the current version of Zuzia.

If you'd like to achieve what's described in this article, please contact us – we'd be happy to work on it and tailor the solution to your needs.

In the meantime, we invite you to try out Zuzia's current features – server monitoring, SSL checks, task management, and many more.

We use cookies to ensure the proper functioning of our website.