Inferensys

Glossary

Autoscaling

Autoscaling is a cloud resource management strategy that automatically adjusts the number of active compute instances in a serving cluster based on real-time metrics like request queue length or CPU utilization, optimizing for cost and performance.
ML engineer managing model training cluster on laptop, GPU utilization visible, technical deep learning setup.
COST AND RESOURCE MANAGEMENT

What is Autoscaling?

Autoscaling is a fundamental cloud resource management strategy for optimizing the cost and performance of LLM inference and other compute-intensive workloads.

Autoscaling is a cloud resource management strategy that automatically adjusts the number of active compute instances (e.g., GPU servers) in a serving cluster based on real-time metrics like request queue length or CPU utilization. This dynamic provisioning optimizes for both cost and performance by scaling out to handle traffic spikes and scaling in during lulls. In LLM operations, it is critical for managing the high cost of GPU instances, ensuring low latency during peak demand while minimizing idle resource expenditure.

Effective autoscaling relies on defining scaling policies tied to metrics such as Tokens Per Second (TPS), request latency, or custom queue depth. It must account for cold start penalties when launching new instances and integrate with load shedding and rate limiting for graceful degradation. As a core FinOps practice, autoscaling, combined with instance right-sizing, provides direct infrastructure cost control for CTOs by aligning resource consumption with actual demand.

CLOUD INFRASTRUCTURE

Key Features of Autoscaling

Autoscaling is a dynamic resource management strategy that automatically adjusts compute capacity based on real-time demand. Its core features are designed to optimize for cost, performance, and reliability in production environments.

01

Reactive Scaling

Reactive scaling adjusts resources after a predefined metric threshold is breached. It is the most common autoscaling pattern.

  • Mechanism: A cloud monitor (e.g., CloudWatch, Prometheus) tracks metrics like CPU utilization, request queue length, or memory usage. When a metric crosses a threshold (e.g., CPU > 70% for 5 minutes), the autoscaler triggers an action to add or remove instances.
  • Use Case: Ideal for workloads with predictable, gradual traffic patterns where a short lag in scaling is acceptable.
  • Example: An e-commerce API scales out from 10 to 15 GPU instances during a peak shopping hour based on rising requests-per-second.
02

Predictive Scaling

Predictive scaling uses historical data and machine learning to proactively adjust capacity before demand changes occur.

  • Mechanism: The autoscaler analyzes time-series data to identify recurring patterns (daily, weekly cycles) and forecasts future load. It schedules scaling actions in advance.
  • Use Case: Critical for workloads with known, periodic spikes (e.g., business hours, scheduled batch jobs) to eliminate cold start latency for users.
  • Example: A video streaming service provisions additional inference servers 30 minutes before the launch of a popular new show, based on viewership patterns.
03

Horizontal vs. Vertical Scaling

Autoscaling implements two fundamental architectural approaches to changing capacity.

  • Horizontal Scaling (Scale-Out/In): Adds or removes entire instances (nodes) to a cluster. This is the standard method for distributed, stateless services like LLM inference endpoints. It improves fault tolerance and handles traffic spikes effectively.
  • Vertical Scaling (Scale-Up/Down): Increases or decreases the compute resources (CPU, GPU, memory) of an existing instance. This is often used for stateful, monolithic applications where distributing load is complex. It typically requires a service restart, causing downtime.

Modern cloud-native LLM serving primarily uses horizontal scaling.

04

Cooldown Periods

A cooldown period is a configurable wait time after a scaling action during which further scaling activities are suspended.

  • Purpose: Prevents rapid, oscillating "flapping" between scale-out and scale-in policies. It allows time for new instances to fully initialize, load the model, and for metrics to stabilize.
  • Mechanism: If CPU drops below the scale-in threshold immediately after adding instances, the cooldown timer prevents premature termination before the new capacity is utilized.
  • Best Practice: Scale-out cooldowns are typically shorter (e.g., 60 seconds) than scale-in cooldowns (e.g., 300 seconds) to allow for more aggressive growth during surges and conservative contraction.
05

Health Checks & Instance Replacement

Autoscaling integrates with health monitoring to ensure only healthy instances serve traffic, maintaining service reliability.

  • Health Checks: The load balancer or service mesh performs periodic HTTP or TCP pings on each instance. Failed checks mark an instance as unhealthy.
  • Automatic Replacement: The autoscaling group automatically terminates unhealthy instances and launches new ones to maintain the desired capacity, enabling self-healing infrastructure.
  • Use Case: Critical for long-running LLM inference servers where GPU memory leaks or software faults can degrade performance over time.
06

Scheduled Scaling

Scheduled scaling allows you to define specific times and dates for capacity changes based on known business events.

  • Mechanism: You create scaling actions that trigger at a predetermined time (e.g., Every Monday at 09:00 UTC, set desired capacity to 20). This is a rule-based form of predictive scaling.
  • Use Case: Perfect for non-variable, time-based workloads like end-of-month reporting jobs, weekly model retraining pipelines, or supporting fixed business hours for a customer service chatbot.
  • Integration: Often used in conjunction with reactive scaling; scheduled scaling sets the baseline capacity, while reactive policies handle unexpected deviations.
LLM SERVING

Autoscaling Strategies: A Comparison

A comparison of core autoscaling strategies for managing GPU inference fleets, highlighting their operational mechanisms, cost implications, and suitability for different LLM workload patterns.

Scaling DimensionReactive ScalingPredictive ScalingScheduled Scaling

Primary Trigger

Real-time metrics (e.g., queue length, GPU utilization)

Forecasted demand (e.g., time-series prediction)

Pre-defined timetable (e.g., business hours)

Scaling Action

Add/remove instances after threshold breach

Proactively add/remove instances before forecasted load

Add/remove instances at scheduled times

Key Advantage

Responds to actual load; simple to implement

Minimizes scaling lag and cold start impact on users

Perfect for predictable, recurring patterns; zero lag

Key Disadvantage

Inherent scaling lag leads to over/under-provisioning

Forecast inaccuracy can cause wasteful provisioning

Inflexible; fails with unexpected traffic spikes

Cost Efficiency

Medium. Prone to over-provisioning during lag periods.

High when forecasts are accurate. Low when inaccurate.

High for perfectly predictable loads. Low otherwise.

Performance Impact

High risk of latency spikes (P95/P99) during scale-out

Optimizes for consistent latency by pre-warming

Consistent performance if schedule matches demand

Complexity

Low

High (requires forecasting pipeline)

Low

Best For

Workloads with moderate, unpredictable fluctuations

Workloads with strong, learnable periodic patterns (e.g., daily peaks)

Workloads with rigid, known schedules (e.g., batch jobs, 9-5 apps)

COST AND RESOURCE MANAGEMENT

LLM-Specific Autoscaling Considerations

Autoscaling for LLMs must account for unique computational patterns, memory constraints, and latency requirements that differ from traditional web services. This section details the critical factors for scaling LLM inference clusters efficiently.

01

Memory-Bound Scaling Triggers

LLM inference is fundamentally memory-bound, not CPU-bound. Standard autoscaling metrics like CPU utilization are poor indicators. The primary scaling trigger is KV Cache memory pressure. When the total allocated KV cache across all concurrent requests approaches the GPU's VRAM limit, new requests must wait or be routed to a new instance. Effective autoscalers monitor:

  • VRAM Utilization: Percentage of GPU memory consumed by model weights, activations, and the KV cache.
  • Request Queue Length: Number of pending inference requests, indicating that existing instances are saturated.
  • P95/P99 Latency: A sustained increase in tail latency signals that instances are overloaded and new ones are needed.
02

Cold Start Latency & Warm Pools

The cold start penalty for LLMs is severe, often taking 30-90 seconds to load a multi-billion parameter model into GPU memory. This makes reactive, metric-driven scaling problematic for spiky traffic. Mitigation strategies include:

  • Warm Instance Pools: Maintaining a buffer of pre-loaded, idle instances that can immediately accept traffic.
  • Predictive Scaling: Using historical traffic patterns (e.g., daily business hour peaks) to proactively scale up before demand arrives.
  • Model Caching Tiers: Keeping frequently used models or model variants (e.g., quantized versions) pre-loaded on a subset of instances for faster horizontal scaling.
03

Batching-Aware Capacity Planning

Throughput and latency are directly governed by dynamic or continuous batching. Autoscaling logic must be aware of the serving engine's batching strategy.

  • Optimal Batch Size: Adding more instances does not linearly increase capacity if the per-instance batch size is suboptimal. The autoscaler should consider whether scaling out or increasing the batch size on existing instances is more efficient.
  • Heterogeneous Requests: Mixes of short (chat) and long (document summarization) requests affect optimal cluster size. Long-running requests can block batch execution, requiring more instances to maintain latency for short requests.
  • GPU Affinity: Some batching strategies work best when a user's session is sticky to a specific instance to leverage cached context. Scaling decisions must consider session affinity to avoid breaking this optimization.
04

Cost-Per-Token Optimization

The goal of autoscaling is to minimize total inference cost, which is a function of instance cost and tokens-per-second (TPS) throughput. Naively scaling to minimize latency can lead to exorbitant costs. Effective systems:

  • Scale on Cost-Efficiency Metrics: Use metrics like (cost per hour) / (tokens per second) to identify when adding a new instance improves overall cluster efficiency.
  • Implement Tiered Scaling: Use a mix of instance types (e.g., cost-optimized for steady state, latency-optimized for peaks) and scale the appropriate tier.
  • Leverage Spot/Preemptible Instances: For batch inference workloads or resilient serving backends, use autoscaling groups with spot instances to significantly reduce costs, with warm pools on on-demand instances as a fallback.
05

Stateful Session Management

LLM applications often involve stateful sessions (e.g., multi-turn conversations where context is cached). Autoscaling must handle this state gracefully.

  • KV Cache Persistence: Scaling in (removing an instance) must not drop active sessions. This requires either session draining (finishing all requests) or a distributed KV cache that can be migrated, a complex feature provided by engines like vLLM.
  • Stateless Serving Layers: A common pattern is to keep the model serving layer stateless by storing conversation context in an external low-latency database. This simplifies scaling but adds overhead for context retrieval on each turn.
06

Integration with Load Shedding & Queuing

Autoscaling works in concert with load shedding and intelligent request queuing. When a scale-up event is triggered, there is an inherent delay. To maintain service-level objectives (SLOs) during this period:

  • Adaptive Queuing: Queue requests with a timeout, rather than immediately rejecting them, to smooth the load while new instances spin up.
  • Priority-Based Shedding: Implement request priorities (e.g., premium user, internal batch job). The system can shed low-priority requests during scaling delays to protect high-priority traffic.
  • Health Check Damping: Use dampening mechanisms to prevent rapid, oscillating scale-up/scale-down events caused by transient traffic spikes, which is costly and disruptive for LLMs.
AUTOSCALING

Frequently Asked Questions

Autoscaling is a foundational cloud strategy for managing the variable and often unpredictable demand of LLM inference. These questions address how it works, its benefits, and its implementation for cost and performance optimization.

Autoscaling is a cloud resource management strategy that automatically adjusts the number of active compute instances (e.g., GPU servers) in a serving cluster based on real-time metrics. For LLM inference, it works by continuously monitoring key performance indicators like request queue length, GPU utilization, or Tokens Per Second (TPS). When a predefined threshold (e.g., average CPU > 70%) is breached, the autoscaler triggers an action via the cloud provider's API to either:

  • Scale Out/Up: Launch new instances to add capacity.
  • Scale In/Down: Terminate underutilized instances to reduce cost.

This creates an elastic pool of resources that expands during traffic spikes and contracts during lulls, optimizing for both performance and inference cost.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.