Skip to main content
Glama
liqcui

OpenShift OVN-Kubernetes Benchmark MCP Server

by liqcui
ovnk_analysis_performance.md9.59 kB
# OVNK Benchmark Performance Analysis - Optimized Version This optimized version extracts common functionality into `ovnk_benchmark_performance_utility.py` while maintaining all existing class names and interfaces in the original files. ## Key Improvements ### 1. Common Utilities (`ovnk_benchmark_performance_utility.py`) - **Base Classes**: `BasePerformanceAnalyzer` for consistent interfaces - **Unified Enums**: `PerformanceLevel`, `AlertLevel`, `ResourceType` - **Utility Classes**: - `MemoryConverter` for consistent memory unit handling - `StatisticsCalculator` for statistical computations - `ThresholdClassifier` for performance classification - `RecommendationEngine` for generating recommendations - `ReportGenerator` for creating reports ### 2. Optimized Modules All original modules now use the common utilities while keeping existing class names: - `OVNKubeSyncDurationAnalyzer` - Enhanced with utility functions - `MultusPerformanceAnalyzer` - Optimized memory conversion and statistics - `OVNKPerformanceAnalyzer` - Unified alert generation and classification - `PerformanceAnalyzer` (pods) - Consistent threshold management - `OVNKPerformanceAnalyzer` (ovs) - Streamlined analysis pipeline ### 3. Unified Entry Point (`ovnk_benchmark_performance_unified.py`) - Single interface for all analyzers - Cross-component analysis - Comprehensive reporting - Command-line integration ## Usage Examples ### Basic Component Analysis ```python # Sync Duration Analysis from ovnk_benchmark_performance_analysis_sync import OVNKubeSyncDurationAnalyzer analyzer = OVNKubeSyncDurationAnalyzer() results = analyzer.analyze_instant_metrics(sync_data) report = analyzer.generate_comprehensive_report(results, collection_info) # Multus Analysis from ovnk_benchmark_performance_analysis_multus import MultusPerformanceAnalyzer analyzer = MultusPerformanceAnalyzer() analysis = analyzer.analyze_pod_usage_data(multus_data) # Container Analysis from ovnk_benchmark_performance_analysis_containers import OVNKPerformanceAnalyzer analyzer = OVNKPerformanceAnalyzer() analysis = analyzer.analyze_performance_data(container_data) ``` ### Unified Analysis ```python from ovnk_benchmark_performance_unified import UnifiedPerformanceAnalyzer # Initialize unified analyzer analyzer = UnifiedPerformanceAnalyzer() # Analyze single component sync_result = analyzer.analyze_component("sync_duration", sync_data) # Analyze multiple components components_data = { "multus": multus_data, "containers": container_data, "sync_duration": sync_data } results = analyzer.analyze_all_components(components_data) # Generate comprehensive report saved_files = analyzer.generate_comprehensive_report(results) ``` ### Using Utility Functions Directly ```python from ovnk_benchmark_performance_utility import ( MemoryConverter, StatisticsCalculator, ThresholdClassifier, RecommendationEngine, PerformanceThreshold ) # Memory conversion mb_value = MemoryConverter.to_mb(1.5, "GB") # Returns 1536.0 # Statistical analysis values = [10.5, 25.2, 30.1, 45.8] stats = StatisticsCalculator.calculate_basic_stats(values) outliers = StatisticsCalculator.detect_outliers_iqr(values) # Performance classification cpu_threshold = ThresholdClassifier.get_default_cpu_threshold() level, severity = ThresholdClassifier.classify_performance(85.0, cpu_threshold) # Recommendations recommendations = RecommendationEngine.generate_resource_recommendations( ResourceType.CPU, level, 85.0, "%" ) ``` ### Command Line Usage ```bash # Quick health check python ovnk_benchmark_performance_unified.py # Analyze from files python ovnk_benchmark_performance_unified.py --files \ multus:multus_metrics.json \ containers:container_metrics.json \ sync_duration:sync_metrics.json ``` ## Sample Data Structures ### Sync Duration Data ```json { "collection_type": "instant", "metrics": { "ovnkube_controller_sync_duration_seconds": { "data": [ {"pod_name": "controller-1", "value": 0.15, "labels": {}}, {"pod_name": "controller-2", "value": 2.5, "labels": {}} ] } } } ``` ### Multus Data ```json { "collection_type": "instant", "top_10_cpu_usage": [ { "pod_name": "multus-daemon-abc", "container_name": "multus", "node_name": "worker-1", "cpu_usage": {"avg": 0.25, "max": 0.4, "unit": "cores"}, "memory_usage": {"avg": 200, "max": 250, "unit": "MB"} } ] } ``` ### Container Metrics Data ```json { "collection_type": "instant", "metrics": { "container_cpu_usage": { "data": [ { "pod_name": "ovnkube-controller", "container_name": "ovnkube-controller", "value": 75.0, "unit": "percent" } ] } } } ``` ## Architecture Benefits ### Code Reduction - **Before**: ~2,000 lines across 5 files with significant duplication - **After**: ~2,500 lines total with shared utility functions (net reduction in complexity) ### Consistency - Unified performance classification across all components - Consistent memory unit handling - Standardized alert generation and severity levels - Common statistical calculations ### Maintainability - Single source of truth for common algorithms - Easier to add new analyzers using base classes - Centralized threshold management - Unified reporting capabilities ### Extensibility - `BasePerformanceAnalyzer` makes adding new components straightforward - `UnifiedAnalysisInterface` supports plugin-style analyzer registration - Common utilities can be enhanced to benefit all analyzers ## Migration Guide ### For Existing Code All original class names and public interfaces remain unchanged: - `OVNKubeSyncDurationAnalyzer` works exactly as before - `MultusPerformanceAnalyzer.analyze_multus_performance()` unchanged - `OVNKPerformanceAnalyzer.analyze_performance_data()` unchanged - All utility functions maintain backward compatibility ### New Features Available - Cross-component analysis via `UnifiedPerformanceAnalyzer` - Enhanced statistical analysis with outlier detection - Consistent performance classification across components - Unified reporting with executive summaries - Command-line interface for batch analysis ## Performance Thresholds ### CPU Thresholds (%) - Excellent: ≤ 20% - Good: ≤ 50% - Moderate: ≤ 75% - Poor: ≤ 90% - Critical: > 90% ### Memory Thresholds (MB) - Excellent: ≤ 1024 (1GB) - Good: ≤ 2048 (2GB) - Moderate: ≤ 4096 (4GB) - Poor: ≤ 8192 (8GB) - Critical: > 8192 (8GB) ### Sync Duration Thresholds (seconds) - Excellent: ≤ 0.1 - Good: ≤ 0.5 - Moderate: ≤ 2.0 - Poor: ≤ 10.0 - Critical: > 10.0 ## Report Outputs ### JSON Reports Structured data suitable for programmatic processing, containing: - Detailed analysis results per component - Performance metrics and statistics - Alert details with severity levels - Cross-component insights - Unified recommendations ### Text Reports Human-readable summaries including: - Executive summary with overall health score - Key findings across components - Performance alerts by severity - Resource utilization summaries - Actionable recommendations ### Health Scores Numerical scores (0-100) for: - Individual components - Overall cluster health - Resource utilization efficiency - Performance trend indicators This optimized architecture provides a robust foundation for OVNK performance analysis while maintaining full backward compatibility and adding powerful new capabilities for comprehensive cluster monitoring. Utility Usage: Uses ThresholdClassifier for performance classification Uses MemoryConverter for memory unit conversions Uses StatisticsCalculator for statistical calculations Uses RecommendationEngine for generating recommendations Uses standardized PerformanceAlert and ClusterHealth data structures Standardized Interface: Implements analyze_metrics_data() method as required by base class Consistent Output: Returns standardized cluster health and analysis metadata structures Changes to ovnk_benchmark_performance_analysis_pods.py: Inheritance: Changed PODsPerformanceAnalyzer to inherit from BasePerformanceAnalyzer Utility Integration: Similar utility class usage as OVS analyzer Alert System: Uses standardized PerformanceAlert objects instead of custom alert structures Report Generation: Uses ReportGenerator utility for consistent report formatting Statistics: Uses StatisticsCalculator for all statistical computations Changes to ovnk_benchmark_performance_unified.py: Import Handling: Added graceful handling for missing analyzer modules Updated Health Extraction: Modified _extract_health_score() to work with the new standardized structures Resource Issue Detection: Updated _has_resource_issues() to work with the new alert format Enhanced Examples: Added specific examples for pods and OVS analysis Command Line Options: Added --health-check option to show available components Key Benefits of These Updates: Code Reusability: Common functionality is now centralized in utility classes Consistency: All analyzers now use the same data structures and calculation methods Maintainability: Changes to thresholds or calculations only need to be made in one place Extensibility: New analyzers can easily inherit from the base class and use utility functions Standardization: All components now produce compatible output formats for unified analysis

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/liqcui/ovnk-benchmark-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server