Overview
Scale your MCP Server horizontally (more replicas) and vertically (more resources) to handle varying loads efficiently. This guide covers Kubernetes HPA, VPA, cluster autoscaling, and performance tuning.IMPORTANT: Redis Checkpointer Required for HPAFor production deployments with horizontal pod autoscaling (HPA), you MUST enable the Redis checkpointer:URL Encoding: If your Redis password contains special characters (Kubernetes deployments using External Secrets should use the
/, +, =, @, etc.), they MUST be percent-encoded per RFC 3986:| urlquery filter to automatically encode passwords.Without Redis, conversation state is stored in pod memory and will be lost during:- Pod restarts
- Scale-up events (new pods have no history)
- Scale-down events (terminated pods lose all state)
- Load balancer routing to different pods
Horizontal Pod Autoscaling (HPA)
Basic Configuration
Advanced HPA
Custom Metrics
Install Prometheus Adapter:Vertical Pod Autoscaling (VPA)
Install VPA
VPA Configuration
Cluster Autoscaling
GKE
EKS
AKS
Load Testing
Generate Load
Monitor Scaling
Resource Limits
Right-Sizing
- Requests: Set to average usage (p50)
- Limits: Set to peak usage (p95-p99)
- CPU: Start with 1 core, adjust based on load
- Memory: 1-2GB for typical workloads
Quality of Service (QoS)
Performance Tuning
Application-Level
Kubernetes-Level
Database Tuning
Redis:Cost Optimization
Right-Size Instances
Spot/Preemptible Instances
GKE:Scheduled Scaling
Monitoring Scaling
Key Metrics
Alerts
Best Practices
Start Conservative
Start Conservative
Begin with conservative scaling settings:
- Min replicas: 3 (for HA)
- Max replicas: 10 (prevent runaway scaling)
- Target CPU: 70% (leave headroom)
- Scale-down delay: 5 minutes (prevent flapping)
Test Thoroughly
Test Thoroughly
Load test before production:
Monitor Closely
Monitor Closely
Track scaling behavior:
- HPA events
- Pod creation/deletion
- Resource utilization
- Request latency
- Error rates
Set Pod Disruption Budget
Set Pod Disruption Budget
Prevent too many pods terminating:
Troubleshooting
HPA not scaling
HPA not scaling
Pods evicted
Pods evicted
Reason: Out of resourcesFix:
- Increase node resources
- Enable cluster autoscaler
- Reduce resource requests
- Add more nodes
Scaling flapping
Scaling flapping
Symptom: Constant scale up/downFix:
Next Steps
Kubernetes Deployment
Deploy to Kubernetes
Monitoring
Set up monitoring
Production Checklist
Scaling requirements
Disaster Recovery
Backup and restore
Auto-Scaling Ready: Handle any load with automatic horizontal and vertical scaling!