Skip to main content

Overview

Proper configuration is essential for FastSkill’s performance, security, and reliability. This guide covers best practices for different deployment scenarios.
Configuration best practices evolve with your application’s needs. Start with defaults and adjust based on monitoring and performance data.

Development Configuration

Hot Reload Setup

Enable hot reloading for faster development cycles:
from fastskill import ServiceConfig
from pathlib import Path

config = ServiceConfig(
    enable_hot_reload=True,
    watch_paths=[
        Path("./skills"),
        Path("./custom-skills"),
        Path("../shared-skills")
    ],
    log_level="DEBUG",
    enable_audit_logging=True,
    cache=CacheConfig(
        cache_ttl_seconds=60  # Short cache for fresh data
    )
)

Development Security

Balance security with development convenience:
config = ServiceConfig(
    execution=ExecutionConfig(
        enable_networking=True,        # Allow external APIs
        sandbox_level="basic",         # Relaxed sandboxing
        max_memory_mb=2048,           # Higher limits for testing
        allowed_paths=[Path("./test-data"), Path("../shared-data")]
    ),
    enable_audit_logging=True,        # Track all operations
    log_level="DEBUG"                 # Detailed logging
)

Production Configuration

Performance Optimization

config = ServiceConfig(
    # High-performance caching
    cache=CacheConfig(
        metadata_cache_size=5000,
        content_cache_size=1000,
        cache_ttl_seconds=3600,       # 1 hour cache
        enable_persistence=True       # Persist to disk
    ),

    # Optimized execution
    execution=ExecutionConfig(
        default_timeout=30,
        max_memory_mb=512,
        max_cpu_percent=75,
        enable_networking=False       # Disable for security
    ),

    # Production monitoring
    enable_metrics=True,
    enable_audit_logging=True,
    log_level="INFO",
    max_concurrent_executions=50
)

Security Hardening

config = ServiceConfig(
    execution=ExecutionConfig(
        enable_networking=False,      # No external network access
        sandbox_level="strict",       # Maximum isolation
        allowed_paths=[],             # Minimal file access
        max_memory_mb=256,           # Lower memory limits
        max_cpu_percent=50           # CPU limits
    ),

    # Security monitoring
    enable_audit_logging=True,
    log_level="WARN",               # Reduce log verbosity
    enable_metrics=True            # Monitor for anomalies
)

Configuration Validation

Always validate configuration before deployment:
# Validate configuration
try:
    config.validate()
    print("✅ Configuration is valid")
except ValidationError as e:
    print(f"❌ Configuration error: {e}")
    # Fix validation errors before proceeding

Environment-Specific Configuration

Docker Deployment

# Dockerfile
FROM fastskill:latest

# Production configuration
ENV FASTSKILL_LOG_LEVEL=WARN
ENV FASTSKILL_EXECUTION_TIMEOUT=30
ENV FASTSKILL_MAX_MEMORY_MB=512
ENV FASTSKILL_ENABLE_HOT_RELOAD=false
ENV FASTSKILL_ENABLE_NETWORKING=false

# Health checks
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
  CMD curl -f http://localhost:8080/health || exit 1

CMD ["fastskill", "serve", "--config", "/app/config/production.json"]

Kubernetes Deployment

# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: fastskill
spec:
  replicas: 3
  selector:
    matchLabels:
      app: fastskill
  template:
    metadata:
      labels:
        app: fastskill
    spec:
      containers:
      - name: fastskill
        image: fastskill:latest
        env:
        - name: FASTSKILL_LOG_LEVEL
          value: "INFO"
        - name: FASTSKILL_STORAGE_PATH
          value: "/app/skills"
        - name: FASTSKILL_EXECUTION_TIMEOUT
          value: "30"
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: "256Mi"
            cpu: "100m"
          limits:
            memory: "1Gi"
            cpu: "500m"
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 30
          periodSeconds: 30
        readinessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 10

Monitoring and Alerting

Configure monitoring for production environments:
config = ServiceConfig(
    # Health monitoring
    enable_health_checks=True,
    health_check_interval_seconds=30,

    # Performance monitoring
    enable_metrics=True,
    metrics_retention_hours=168,  # 1 week retention

    # Logging configuration
    enable_audit_logging=True,
    log_level="INFO",

    # Alert thresholds
    max_concurrent_executions=100,  # Alert if exceeded
    enable_performance_alerts=True
)

Configuration Management

Version Control

Store configuration in version control:
config/
├── development.json
├── staging.json
├── production.json
└── testing.json

Configuration Templates

# config/templates/production.py
def get_production_config():
    return ServiceConfig(
        skill_storage_path=Path("/opt/fastskill/skills"),
        execution=ExecutionConfig(
            default_timeout=30,
            max_memory_mb=512,
            enable_networking=False,
            sandbox_level="strict"
        ),
        enable_hot_reload=False,
        enable_metrics=True,
        log_level="INFO"
    )

# config/templates/development.py
def get_development_config():
    return ServiceConfig(
        skill_storage_path=Path("./skills"),
        execution=ExecutionConfig(
            default_timeout=60,
            max_memory_mb=2048,
            enable_networking=True,
            sandbox_level="basic"
        ),
        enable_hot_reload=True,
        enable_metrics=True,
        log_level="DEBUG"
    )

Performance Tuning

Memory Optimization

# Memory-optimized configuration
config = ServiceConfig(
    cache=CacheConfig(
        metadata_cache_size=1000,    # Reduced from default
        content_cache_size=100,      # Reduced from default
        enable_persistence=True      # Use disk cache
    ),

    execution=ExecutionConfig(
        max_memory_mb=256,          # Lower per-execution limit
        max_cpu_percent=50          # CPU limit
    ),

    max_concurrent_executions=20    # Lower concurrency
)

High-Throughput Configuration

# High-throughput configuration
config = ServiceConfig(
    cache=CacheConfig(
        metadata_cache_size=10000,   # Large cache
        content_cache_size=2000,     # Large content cache
        cache_ttl_seconds=7200       # 2 hour cache
    ),

    execution=ExecutionConfig(
        default_timeout=10,         # Faster timeout
        max_memory_mb=128,          # Lower memory per execution
        max_cpu_percent=100         # Full CPU usage
    ),

    max_concurrent_executions=100,  # High concurrency
    enable_metrics=True            # Monitor performance
)

Security Best Practices

1

Principle of least privilege

Configure minimum necessary permissions for skills and services.
2

Regular security audits

Review configuration changes and security settings regularly.
3

Environment separation

Use different configurations for development, staging, and production.
4

Access logging

Enable audit logging to track all operations and changes.

Troubleshooting Configuration

Common Issues

Restart required: Some configuration changes require service restart.
# Check if restart is needed
fastskill status --detailed

# Restart service
fastskill restart --config new-config.json
Monitor metrics: Use built-in metrics to identify configuration bottlenecks.
metrics = await service.get_metrics()
print(f"Cache hit rate: {metrics['cache_hit_rate']}")
print(f"Average response time: {metrics['avg_response_time_ms']}ms")
Gradual hardening: Implement security measures gradually to avoid breaking functionality.
Configuration is a balance between security, performance, and functionality. Monitor your application’s behavior and adjust configuration based on real-world usage patterns.