A comprehensive Redis cache monitoring and diagnostics extension for CiviCRM. This extension provides detailed health checks and performance metrics through the CiviCRM System Status Check interface.
- Redis connection status (Connected/Not Connected)
- Network reachability verification
- Response time and latency measurement
- Authentication validation
- Redis version detection
- Cache backend verification
- Configuration constant validation
- Key prefix monitoring
- Cache timeout (TTL) tracking
- Password authentication status
- Real-time memory usage tracking
- Memory fragmentation ratio monitoring
- Key capacity insights
- Hit/miss statistics
- Commands per second throughput
- Connection efficiency metrics
- Total keys count
- CiviCRM-specific key count
- Write/read operation testing
- Key pattern analysis
- Cache effectiveness measurement
- Eviction policy verification
- Persistence configuration (RDB/AOF)
- Client connection management
- Slow query log analysis capability
- Memory pressure indicators
- CiviCRM 5.0+
- PHP Redis extension installed (
php-redis) - Redis server configured in CiviCRM
-
Download the extension to your CiviCRM extensions directory:
cd /path/to/civicrm/extensions git clone https://github.com/Skvare/com.skvare.redis_healthcheck.git -
Enable the extension in CiviCRM:
- Navigate to Administer > System Settings > Extensions
- Find "Redis Health Check"
- Click "Install"
-
Verify Redis PHP extension is installed:
php -m | grep redisIf not installed:
# For Ubuntu/Debian sudo apt-get install php-redis # For RHEL/CentOS sudo yum install php-pecl-redis # Or using pecl pecl install redis
The extension requires Redis to be configured in your civicrm.settings.php:
// Enable Redis caching
define('CIVICRM_DB_CACHE_CLASS', 'Redis');
define('CIVICRM_DB_CACHE_HOST', 'localhost');
define('CIVICRM_DB_CACHE_PORT', 6379);
define('CIVICRM_DB_CACHE_PREFIX', 'civicrm_');
define('CIVICRM_DB_CACHE_TIMEOUT', 3600);
// Optional: If Redis requires password authentication
define('CIVICRM_DB_CACHE_PASSWORD', 'your-redis-password');- Navigate to Administer > System Settings > System Status
- Scroll to the "Redis Health Check" section
- Review the detailed diagnostics
Green (OK)
- All checks passed successfully
- System is operating normally
Yellow (Warning)
- Minor issues detected
- Attention may be needed but not critical
- Examples: High memory usage (80-90%), High latency (>50ms)
Red (Error)
- Critical issues detected
- Immediate action may be required
- Examples: Connection failed, Redis unreachable, Memory critical (>90%)
Response Time
- Time it takes Redis to respond to a PING command
- Normal: <10ms on localhost, <50ms on network
- High latency indicates network issues or Redis overload
Memory Usage
- Used: Current memory consumed
- Max: Maximum memory available (if configured)
- Fragmentation: Ratio of physical memory vs allocated (>1.5 indicates fragmentation)
Cache Hit Ratio
- Percentage of successful cache lookups
- Higher is better (>80% is good)
- Low ratio may indicate cache misconfiguration
Evicted Keys
- Number of keys removed when memory limit reached
- High eviction indicates insufficient memory
- Review
maxmemory-policyconfiguration
Connected Clients
- Number of active connections to Redis
- Monitor for connection leaks
- Warning if approaching max connections
Install the PHP Redis extension:
# Ubuntu/Debian
sudo apt-get install php-redis
sudo systemctl restart php-fpm # or apache2
# RHEL/CentOS
sudo yum install php-pecl-redis
sudo systemctl restart httpd- Verify Redis is running:
redis-cli ping - Check host and port configuration
- Verify firewall allows connections
- Ensure
CIVICRM_DB_CACHE_HOSTandCIVICRM_DB_CACHE_PORTare correct
- Verify the password in
CIVICRM_DB_CACHE_PASSWORDis correct - Check Redis server requires authentication:
redis-cli config get requirepass - Test connection:
redis-cli -h host -p port -a password ping
- Check evicted keys - indicates insufficient memory
- Review cache timeout - too long means stale keys persist
- Consider increasing Redis
maxmemoryconfiguration - Clear cache:
redis-cli FLUSHDB
- Fragmentation ratio >1.5 indicates inefficient memory use
- Solution: Restart Redis server (downtime required)
- Consider upgrading Redis version
- Monitor cache key sizes
- May indicate cache keys expire too quickly
- Verify
CIVICRM_DB_CACHE_TIMEOUTis appropriate - Check for multiple CiviCRM instances overwriting cache
- Monitor key prefix to ensure no conflicts
The extension implements hook_civicrm_check to provide diagnostics:
function redis_healthcheck_civicrm_check(&$messages) {
// Extension automatically adds Redis health checks
// No custom implementation needed
}CIVICRM_DB_CACHE_CLASS // Cache backend (must be 'Redis')
CIVICRM_DB_CACHE_HOST // Redis server hostname
CIVICRM_DB_CACHE_PORT // Redis server port (default: 6379)
CIVICRM_DB_CACHE_PASSWORD // Redis password (optional)
CIVICRM_DB_CACHE_TIMEOUT // Cache TTL in seconds (default: 3600)
CIVICRM_DB_CACHE_PREFIX // Key prefix for CiviCRM keysThe health check extension has minimal performance impact:
- Checks run only when System Status page is accessed
- Average check execution: 100-500ms
- No background processes or scheduled jobs
- No data modification, read-only operations
For issues or feature requests:
AGPLv3 - See LICENSE file for details
Developed by Skvare, LLC for the CiviCRM community.
Skvare LLC specializes in CiviCRM development, Drupal integration, and providing technology solutions for nonprofit organizations, professional societies, membership-driven associations, and small businesses. We are committed to developing open source software that empowers our clients and the wider CiviCRM community.
Contact Information:
- Website: https://skvare.com
- Email: info@skvare.com
- GitHub: https://github.com/Skvare
Contact us for support or to learn more.