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.
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
└────────────────────┘- Collect runtime metrics using
monitor_service.pyor FlowAudit - Engineer features: lag, rolling averages, time-based signals
- Train a model using
trainer.pyand serialize it - Load the model in
estimator.pyfor live predictions - Evaluate and monitor model performance and drift
- Retrain periodically to adapt to new workloads
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
}Restima produces a prediction block:
{
"ram_mb": 1536.2,
"cpu_cores": 3.7,
"io_mb": 320.0,
"confidence": "High"
}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.jsonlgit clone https://github.com/your-org/restima.git
cd restima
pip install -e .Ensure the following directories exist:
models/→ stores trained modelsdata/→ stores training and live metric files
| 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 |
- ✅ 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
| 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 |
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
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.