Production Setup
Best practices for deploying Epochly in production environments.
Installation with Doctor Check
# Install Epochlypip install epochly# Run system compatibility checkepochly doctor
The epochly doctor command verifies:
- Python version compatibility
- Required dependencies
- System resources (CPU, memory)
- Optional features availability
System Requirements
| Component | Minimum | Recommended | Notes |
|---|---|---|---|
| Python | 3.9+ | 3.11+ | Full support, 3.12+ preferred |
| CPU Cores | 2+ | 4+ | Level 3+ requires 4+ cores |
| Memory | 512MB+ | 2GB+ | Depends on workload size |
| Disk Space | 100MB | 500MB | For cache and JIT compilation |
| OS | Linux/macOS/Windows | Linux | Best performance on Linux |
| GPU (Level 4) | CUDA 11.0+ | CUDA 12.0+ | NVIDIA GPU for acceleration |
Conservative Production Settings
Start with conservative settings for production:
export EPOCHLY_LEVEL=2export EPOCHLY_MODE=conservativeexport EPOCHLY_MAX_WORKERS=4export EPOCHLY_LOG_LEVEL=WARNING
Configuration File (epochly.toml)
Create epochly.toml in your project root:
[epochly]level = 2mode = "conservative"max_workers = 8[epochly.logging]level = "WARNING"file = "/var/log/epochly.log"[epochly.monitoring]prometheus_enabled = trueprometheus_port = 9090[epochly.jit]hot_path_threshold = 1000cache_enabled = true
Level Selection Guidelines
| Level | Risk | Production Ready? | Use Case |
|---|---|---|---|
| 0 | None | ✅ Yes | Monitoring only |
| 1 | Low | ✅ Yes | Threading optimization |
| 2 | Low | ✅ Yes | JIT compilation (recommended) |
| 3 | Medium | ⚠️ Test first | Full parallelism |
| 4 | Medium | ⚠️ Requires license | GPU acceleration |
Level 2 (Recommended)
export EPOCHLY_LEVEL=2export EPOCHLY_MODE=conservative
Benefits:
- JIT compilation for hot code paths
- Threading optimizations
- Minimal risk profile
- No license required
Activation Methods
1. CLI Runner
# Simple usageepochly app.py# With configurationepochly run --level 2 --mode conservative app.py# With argumentsepochly app.py arg1 arg2 --option value
2. sitecustomize (Recommended for Production)
epochly sitecustomize installexport EPOCHLY_AUTO_ENABLE=1export EPOCHLY_MODE=conservativepython your_app.py
3. Programmatic
import epochlyepochly.configure(enhancement_level=2,mode='conservative',max_workers=8)# Your application code
Resource Management
CPU Configuration
import epochlyimport os# Match CPU corescpu_count = os.cpu_count() or 4epochly.configure(max_workers=cpu_count,cpu_affinity=True # Pin workers to specific cores)
Memory Limits
# Set memory limitsexport EPOCHLY_MEMORY_SHARED_SIZE=67108864 # 64MBexport EPOCHLY_MEMORY_POOL_TYPE=shared
Prometheus Monitoring
import epochly# Enable metrics exportepochly.configure(prometheus_enabled=True,prometheus_port=9090)# Check statusstatus = epochly.get_status()metrics = epochly.get_metrics()
High Availability
Graceful Degradation
Epochly automatically degrades gracefully:
- Monitors for errors and performance issues
- Rolls back to lower enhancement level if problems detected
- Logs degradation events
- Recovers automatically when stable
Horizontal Scaling
- Each process has independent Epochly state
- No shared state between workers
- Safe for multi-instance deployments
- Works with load balancers
Logging Configuration
import epochlyepochly.configure(log_level='WARNING', # Reduce verbositylog_file='/var/log/epochly.log',log_format='json' # Structured logging)
Security Best Practices
- License Keys: Use environment variables, never hardcode
- Logging: Avoid logging sensitive data
- Permissions: Run with minimal required permissions
- Network: Epochly makes no external network calls (except license validation)
Health Check Endpoint
from flask import Flask, jsonifyimport epochlyapp = Flask(__name__)@app.route('/health/epochly')def epochly_health():status = epochly.get_status()return jsonify({'healthy': status['initialized'],'level': status['enhancement_level'],'mode': status['mode'],'workers': status.get('active_workers', 0)})
Pre-Deployment Checklist
Before deploying Epochly to production:
- [ ] Installation Verified: Run
epochly doctorto verify system compatibility - [ ] Configuration Set: Environment variables or
epochly.tomlconfigured - [ ] Conservative Settings: Start with
EPOCHLY_LEVEL=2andEPOCHLY_MODE=conservative - [ ] Resource Limits: CPU and memory limits configured appropriately
- [ ] Monitoring Enabled: Prometheus or metrics collection configured
- [ ] Logging Configured: Log level set to WARNING or ERROR for production
- [ ] Health Checks: Health check endpoint implemented and tested
- [ ] Emergency Controls: Document emergency disable procedures
- [ ] Staging Tested: Tested in staging environment with production-like load
- [ ] Rollback Plan: Emergency disable and rollback procedures documented
- [ ] License Validated: Pro/Enterprise license key verified (if using Level 4)
- [ ] Security Review: License keys in environment variables, not hardcoded
Post-Deployment Checklist
After deploying Epochly:
- [ ] Verify Initialization: Check
/health/epochlyendpoint returns healthy status - [ ] Monitor Metrics: Watch CPU, memory, and Epochly-specific metrics
- [ ] Check Logs: Review logs for any errors or warnings
- [ ] Validate Performance: Compare baseline performance metrics
- [ ] Test Emergency Disable: Verify
EPOCHLY_EMERGENCY_DISABLE=1works - [ ] Monitor for 24 hours: Watch for memory leaks or degradation
- [ ] Document Configuration: Record all settings and performance baselines
- [ ] Alert Configuration: Set up alerts for high error rates or degradation
Troubleshooting Production Issues
High Memory Usage
# Reduce max workersexport EPOCHLY_MAX_WORKERS=2# Limit shared memory poolexport EPOCHLY_MEMORY_SHARED_SIZE=33554432 # 32MB# Restart application
Performance Degradation
# Drop to lower levelexport EPOCHLY_LEVEL=1# Or switch to monitoring onlyexport EPOCHLY_MODE=monitoring# Restart and monitor
Unexpected Errors
# Enable debug logging temporarilyexport EPOCHLY_LOG_LEVEL=DEBUG# Check logstail -f /var/log/epochly.log# Disable if neededexport EPOCHLY_EMERGENCY_DISABLE=1