https://github.com/syswe/llm-phpa
π€ LLM-powered Predictive Horizontal Pod Autoscaling for Kubernetes with intelligent pattern recognition
https://github.com/syswe/llm-phpa
Last synced: 11 months ago
JSON representation
π€ LLM-powered Predictive Horizontal Pod Autoscaling for Kubernetes with intelligent pattern recognition
- Host: GitHub
- URL: https://github.com/syswe/llm-phpa
- Owner: syswe
- Created: 2025-07-01T09:56:36.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-01T10:04:30.000Z (11 months ago)
- Last Synced: 2025-07-01T10:47:26.525Z (11 months ago)
- Language: Python
- Size: 0 Bytes
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Predictive Horizontal Pod Autoscaling: A Pattern-Aware Framework with Large Language Model Integration
## π― Project Overview
This repository contains the complete implementation and research framework for **"LLM Pattern Recognition for Predictive Horizontal Pod Autoscaling"** - a comprehensive master thesis research project that establishes foundational components for intelligent Kubernetes autoscaling through integration of advanced machine learning techniques, sophisticated hyperparameter optimization frameworks, and automated pattern recognition capabilities.
### π¬ Research Context
Traditional Kubernetes autoscaling relies on reactive heuristic methods that fail to capture complex temporal dependencies in modern microservices workloads. This research addresses these limitations through the development of Predictive Horizontal Pod Autoscaling (PHPA) incorporating advanced hyperparameter optimization frameworks that anticipate future resource requirements before they manifest as performance bottlenecks.
## ποΈ System Architecture
The research framework consists of three interconnected modules that collectively establish a comprehensive approach to intelligent autoscaling:

## π Key Research Contributions
### 1. **Comprehensive Pattern Taxonomy** (Module 1)
- **Six mathematically-formulated pattern types** covering the full spectrum of production workload behaviors
- **Over 2 million data points** across 600 distinct scenarios for robust algorithm evaluation
- **Real-world calibration** validated against NASA web servers, FIFA World Cup datasets, and cloud application logs
- **Statistical rigor** with 15-minute granularity over 35-day periods with realistic Kubernetes constraints
### 2. **Advanced Model Selection Framework** (Module 2)
- **37.4% average improvement** in forecasting accuracy through pattern-specific model selection
- **Seven CPU-optimized models** with comprehensive hyperparameter optimization
- **Production-ready performance** with training times 0.02-0.61s, memory usage 42-210MB
- **Advanced optimization strategies** including temporal cross-validation and early stopping
### 3. **LLM-Powered Pattern Recognition** (Module 3)
- **96.7% overall accuracy** in pattern classification with Gemini 2.5 Pro
- **Multimodal analysis** supporting both text-based CSV and visual chart analysis
- **Automated model recommendation** based on detected workload patterns
- **Democratic access** to sophisticated temporal analysis capabilities
## π Module Integration and Relationships
### Data Flow Architecture
1. **Pattern Generation** β Creates comprehensive synthetic datasets representing six fundamental workload types
2. **Model Training** β Evaluates forecasting models across generated patterns with optimization
3. **LLM Recognition** β Automatically identifies patterns and recommends optimal models
4. **PHPA Framework** β Integrates all components for intelligent autoscaling decisions
### Mathematical Foundation
The research establishes pattern-driven optimization as:
```
min ΞΈα΅’ E[L(yβ, fα΅’(xβ; ΞΈα΅’))] subject to pβ β Pα΅’
```
Where `fα΅’` represents the optimal model for pattern type `i`, `ΞΈα΅’` denotes pattern-specific optimized hyperparameters, and `Pα΅’` defines the pattern classification space.
## π Repository Structure
```
phpa/
βββ 1-dataset-generation/ # Module 1: Pattern Generation System
β βββ scripts/ # Pattern generation and validation
β β βββ patterns/ # Six pattern implementations
β β βββ config/ # Configuration management
β β βββ utils/ # Utilities and plotting
β βββ README.md # Detailed module documentation
β
βββ 2-ml-training/ # Module 2: ML Model Training Framework
β βββ scripts/ # Training and evaluation scripts
β β βββ cpu-models/ # Production-ready CPU models
β β βββ gpu-models/ # Advanced GPU-accelerated models
β βββ README.md # Detailed module documentation
β
βββ 3-llm-pattern-recognition/ # Module 3: LLM Integration System
β βββ scripts/ # LLM evaluation and benchmarking
β βββ config.yaml.example # Configuration template
β βββ README.md # Detailed module documentation
β
βββ sections-en/ # Academic Paper Sections
β βββ 1-introduction.tex # Research introduction and context
β βββ 7-architecture.tex # Proposed PHPA architecture
β βββ 8-discussion.tex # Critical analysis and implications
β βββ 9-conclusion.tex # Conclusions and future directions
β βββ 10-acknowledgment.tex # Acknowledgments
β
βββ README.md # This comprehensive overview
```
## π Quick Start Guide
### Prerequisites
- Python 3.8+
- Docker (optional, for containerized deployment)
- Kubernetes cluster (for production testing)
- API keys for LLM providers (Gemini, Qwen, Grok)
### 1. Dataset Generation
```bash
cd 1-dataset-generation/scripts
python generate_patterns.py --output-dir complete_dataset --days 35
```
### 2. Model Training
```bash
cd 2-ml-training/scripts
python train-models.py --models "xgboost,lightgbm,prophet"
```
### 3. LLM Pattern Recognition
```bash
cd 3-llm-pattern-recognition
cp config.yaml.example config.yaml
# Configure API keys
python scripts/enhanced_benchmark.py --llm all --method all
```
## π Research Results and Validation
### Empirical Performance Metrics
| Component | Metric | Result |
|-----------|--------|--------|
| **Pattern-Specific vs Universal** | MAE Improvement | **37.4%** |
| **LLM Pattern Recognition** | Overall Accuracy | **96.7%** |
| **Model Training Time** | Range | **0.02-0.61s** |
| **Memory Usage** | Range | **42-210MB** |
| **Dataset Coverage** | Total Data Points | **2M+** |
| **Scenario Diversity** | Unique Scenarios | **600** |
### Pattern-Model Optimization Results
| Pattern Type | Optimal Model | Win Rate | MAE | Optimization Strategy |
|--------------|---------------|----------|-----|----------------------|
| **Growing** | VAR | 96% | 2.44 | BIC lag selection |
| **On/Off** | CatBoost | 62% | 0.87 | Ordered boosting |
| **Seasonal** | GBDT | 45% | 1.89 | Learning rate-depth optimization |
| **Burst** | GBDT | 42% | 2.13 | Histogram-based construction |
| **Chaotic** | GBDT | 38% | 2.45 | Advanced regularization |
| **Stepped** | GBDT | 35% | 1.97 | Depth optimization |
## π¬ Scientific Methodology
### 1. Pattern Taxonomy Development
Six fundamental Kubernetes workload patterns with mathematical formulations:
- **Seasonal**: `P_t = B + βA_k sin(2Οt/T_k + Ο_k) + N_t`
- **Growing**: `P_t = B + GΒ·f(t) + SΒ·sin(2Οh_t/24) + N_t`
- **Burst**: `P_t = B + βB_iΒ·g(t-t_i,d_i)Β·1_{t_iβ€t