Skip to main content

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 (/, +, =, @, etc.), they MUST be percent-encoded per RFC 3986:
Kubernetes deployments using External Secrets should use the | 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
See ADR-0022: Distributed Conversation Checkpointing for details.

Horizontal Pod Autoscaling (HPA)

Basic Configuration

Deploy:

Advanced HPA

Custom Metrics

Install Prometheus Adapter:
Configure custom metrics:

Vertical Pod Autoscaling (VPA)

Install VPA

VPA Configuration

Check recommendations:

Cluster Autoscaling

GKE

EKS

AKS

Load Testing

Generate Load

Monitor Scaling

Resource Limits

Right-Sizing

Guidelines:
  • 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:
PostgreSQL:

Cost Optimization

Right-Size Instances

Spot/Preemptible Instances

GKE:
EKS:

Scheduled Scaling

Monitoring Scaling

Key Metrics

Alerts

Best Practices

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)
Load test before production:
Track scaling behavior:
  • HPA events
  • Pod creation/deletion
  • Resource utilization
  • Request latency
  • Error rates
Prevent too many pods terminating:

Troubleshooting

Reason: Out of resourcesFix:
  • Increase node resources
  • Enable cluster autoscaler
  • Reduce resource requests
  • Add more nodes
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!