The ProcessMaker Cache Monitoring System is a comprehensive solution for tracking and analyzing cache performance metrics in real-time. It uses Redis as a backend store for metrics and provides detailed insights into cache usage patterns, hit/miss rates, and memory consumption.
-
Core Components:
CacheMetricsInterface: Defines the contract for metrics collectionPrometheusMetricsManager: Implements metrics storage using RedisCacheMetricsDecorator: Wraps cache implementations to collect metrics
-
Key Features:
- Real-time metrics collection
- Hit/miss rate tracking
- Response time monitoring
- Memory usage tracking
- Top keys analysis
- Performance insights
-
Storage Strategy:
- Uses Redis hash structures for counters
- Maintains rolling lists for timing data
- Prefix-based key organization
- Automatic cleanup of old data
- Cache hits and misses
- Response times for hits/misses
- Memory usage per key
- Last write timestamps
- Access patterns
- Overall performance statistics
The current Redis-based implementation was chosen because:
- Performance: Redis provides fast read/write operations
- Data Structures: Native support for counters and lists
- TTL Support: Automatic expiration of old metrics
- Scalability: Easy to scale horizontally
- Integration: Already used in ProcessMaker's infrastructure
// Get hit rate for a specific key
$hitRate = $metrics->getHitRate('my_cache_key');
// Get memory usage
$usage = $metrics->getMemoryUsage('my_cache_key');
// Get performance summary
$summary = $metrics->getSummary();// Get top accessed keys
$topKeys = $metrics->getTopKeys(10);
// Analyze response times
$avgHitTime = $metrics->getHitAvgTime('my_cache_key');
$avgMissTime = $metrics->getMissAvgTime('my_cache_key');- Aggregation: Add support for metric aggregation by time periods
- Sampling: Implement sampling for high-traffic scenarios
- Alerts: Add threshold-based alerting system
- Visualization: Integrate with monitoring dashboards
- Custom Metrics: Allow adding custom metrics per cache type
The Redis-based monitoring system provides a good balance between performance, functionality, and maintainability. While there are alternatives available, the current implementation meets ProcessMaker's requirements for real-time cache monitoring with minimal overhead.