Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


🧠 Restima: Predictive Resource Estimation Engine

Restima is a hybrid resource estimation system designed for modern infrastructure and AI workloads. It combines rule-based logic with machine learning to predict CPU, memory, and I/O requirements based on runtime metrics. Built with modularity, observability, and MLOps in mind, Restima adapts to evolving workloads and improves over time.


📐 Architectural Overview

Restima follows a Model-as-a-Service architecture:

┌────────────────────┐
│ monitor_service.py │ ← Collects live metrics
└────────┬────────────┘
         ↓
┌────────────────────┐
│ trainer.py         │ ← Feature engineering + model training
└────────┬────────────┘
         ↓
┌────────────────────┐
│ registry.py        │ ← Stores model metadata
└────────┬────────────┘
         ↓
┌────────────────────┐
│ estimator.py       │ ← Loads model + predicts resources
└────────┬────────────┘
         ↓
┌────────────────────┐
│ cli.py             │ ← User interface for training, inference, evaluation
└────────────────────┘

🧠 Thoughtflow

  1. Collect runtime metrics using monitor_service.py or FlowAudit
  2. Engineer features: lag, rolling averages, time-based signals
  3. Train a model using trainer.py and serialize it
  4. Load the model in estimator.py for live predictions
  5. Evaluate and monitor model performance and drift
  6. Retrain periodically to adapt to new workloads

📥 Input Format

Restima expects structured runtime metrics in JSONL format:

{
  "timestamp": "2025-09-06T13:00:01Z",
  "avg_cpu_percent": 65.2,
  "peak_memory_mb": 1450,
  "total_io_mb": 320,
  "call_depth": 12,
  "branching_factor": 3.1,
  "recursion_detected": true,
  "avg_latency_sec": 0.24
}

📤 Output Format

Restima produces a prediction block:

{
  "ram_mb": 1536.2,
  "cpu_cores": 3.7,
  "io_mb": 320.0,
  "confidence": "High"
}

🧪 CLI Commands

restima monitor --duration 60
restima train --data data/training_data.jsonl
restima estimate --metrics data/live_metrics.jsonl --output prediction.json
restima evaluate --model models/predictor_model.pkl --data data/eval_data.jsonl
restima drift --baseline data/baseline.jsonl --live data/live_metrics.jsonl

⚙️ Setup Instructions

git clone https://github.com/your-org/restima.git
cd restima
pip install -e .

Ensure the following directories exist:

  • models/ → stores trained models
  • data/ → stores training and live metric files

🔁 Summary of Improvements

Area Before After
Estimation Logic Static formula Hybrid ML + fallback
Data Handling Manual Automated ingestion via monitor_service
Feature Engineering Basic Lag, rolling, time-based
CLI Single command Modular commands for training, inference, evaluation
Retraining Manual Drift-aware, schedulable
Accuracy Fixed Adaptive, data-driven

🧠 Strategic Benefits

  • Improved Accuracy: Learns from historical patterns and adapts to new data
  • Adaptability: Retrains on fresh metrics to handle evolving workloads
  • Cost Efficiency: Reduces over-provisioning and optimizes cloud spend
  • Observability: Logs predictions and tracks model performance
  • MLOps Foundation: Ready for integration with MLflow, Airflow, or CI/CD
  • Lightweight Deployment: Fast inference with minimal overhead

🧰 How to Use Restima

Scenario How to Use
CI/CD pipeline Add restima estimate as a post-test step
FlowAudit integration Use flowaudit export --format restima --features
Model training Run restima train on historical traces
Drift detection Schedule restima drift weekly
Dashboard integration Log predictions and confidence scores to Grafana or Slack

📈 Strategic Impact

Restima transforms runtime metrics into actionable infrastructure intelligence. It empowers teams to:

  • Predict resource needs before deployment
  • Optimize provisioning based on real usage
  • Detect architectural inefficiencies
  • Automate scaling decisions with confidence

📃 License

MIT License


Restima is now a living system — continuously learning, adapting, and optimizing. Let me know if you’d like to generate a sample training dataset, simulate a full CI/CD run, or scaffold a dashboard integration next.

About

lightweight Python library that helps you predict how much resource your tasks will need — before deployment.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages