Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Graceful Degradation with Smaller Models

In our last session, we built a crucial safety net for our LLM service by implementing fallback strategies for when a model fails outright. This ensures continuity, but as an SRE, you know that a service can be "up" but still unusable due to poor performance. A response that takes 30 seconds might as well be an error for an interactive chat application.

This lesson advances our reliability journey from reactive failure handling to proactive performance management. We'll focus on how to implement graceful degradation by routing to a smaller model when P99 latency exceeds its Service Level Objective (SLO). This is a sophisticated pattern that allows your system to automatically shed load and maintain responsiveness by making a trade-off between response quality and speed, directly protecting the user experience during periods of high demand.

We will cover:

  1. The role of smaller, faster models as viable alternatives.
  2. How to define and use latency SLOs as the trigger for degradation.
  3. The architecture of a latency-aware gateway that can execute this routing logic.

1. The Rationale: Why Route to a Smaller Model?

Graceful degradation implies having a "lesser" but still functional state to fall back to. In the world of LLMs, this often means using a smaller, faster model. While large models offer superior reasoning, smaller models are increasingly capable and provide significant advantages in speed and cost-efficiency, making them perfect candidates for a performance-driven fallback.

Let's explore the trade-offs and capabilities of different model sizes.

Small vs. Large AI Models: Trade-offs & Use Cases Explained

This video from IBM Technology, "Small vs. Large AI Models," provides an excellent overview of the model size landscape and why smaller models are often preferable.

Please watch the following sections: Model Size Trade-offs: This section introduces the core concept: larger models offer more capability at a higher cost in compute, memory, and energy. Smaller Models Catching Up: Pay attention to the discussion around the MMLU benchmark. It shows how quickly smaller models are achieving competent generalist behavior, making them credible alternatives. Use Cases for Small Models: This part is key. It highlights scenarios like on-device AI that demand sub-100ms latency and notes that for tasks like summarization, a small model can be "30 times cheaper and faster" for statistically indistinguishable results. This directly supports their use as a latency-saving fallback.

The key takeaway is that for many requests, a smaller model can deliver acceptable quality with significantly lower latency. This makes them the ideal target when our primary, larger model is struggling to meet its performance SLOs.

2. The Trigger: P99 Latency and Service Level Objectives (SLOs)

To trigger graceful degradation, we need a clear, measurable signal that performance is suffering. In SRE practice, this is the role of an SLO. For LLM services, latency is a critical Service Level Indicator (SLI), and we typically monitor several facets of it.

A typical monitoring dashboard for an LLM service, visualizing key metrics including request latency percentiles (P99, P90, P50) which are crucial for defining and monitoring SLOs.

The StackAI article below provides a great breakdown of the essential metrics and the concept of a "model cascade," which is the architectural pattern we're implementing.

Reduce AI Latency in Production: Optimize Token Usage, Caching ...

This article from Stack-AI is a practical playbook for latency optimization. We'll focus on the sections that help us define our trigger and the architectural response.

Please read the following sections: "Before you change anything, define success in numbers": This introduces the key latency metrics: TTFT (Time to First Token), generation speed (TPS), and critically, end-to-end latency (especially p95/p99). "Definitions (use these in dashboards)": This provides clear definitions for TTFT, TPS, and p95/p99 latency. These are the specific SLIs you would monitor. "SLOs to set (example targets)": Your SRE background makes you an expert in SLOs, but this section provides excellent, LLM-specific examples. Note the different latency budgets for interactive chat vs. background summarization. Our graceful degradation strategy must be context-aware. "Model routing (tiering) to meet latency budgets": This section describes the model cascade pattern. The idea of trying a "fast, cheap model first" can be inverted for our use case: try the best model first, and if it's predicted to be too slow, escalate (or in this case, de-escalate) to a faster one.

With these concepts, we can define our trigger precisely:

  • SLI: P99 end-to-end request latency.
  • SLO: For an interactive chat, we might set a P99 latency SLO of < 6 seconds.
  • Trigger Condition: The system predicts that a request to the primary (large) model will exceed the 6-second SLO.

Now, how do we implement the system that makes this prediction and routes the request accordingly?

3. The "How": Implementing Latency-Based Routing

The logic for this graceful degradation pattern belongs in a smart routing layer or API gateway. This component sits in front of your model deployments and makes intelligent, request-by-request decisions. Your experience with ingress controllers and service meshes in Kubernetes is directly applicable here.

This reference architecture for an AI Gateway shows 'Model Routing' as a core component. This is where logic for graceful degradation, based on latency or other factors, would reside.

A concrete example of such a system is the Kubernetes Gateway API Inference Extension, which provides a plugin for latency-based routing. It's designed for exactly the scenario we're discussing.

Latency-Based Routing - Kubernetes Gateway API Inference Extension

This documentation details a sophisticated routing mechanism built for LLM inference on Kubernetes. It explains how to route requests based on latency predictions against SLOs.

As you read, focus on the mechanism itself: High-Level Concept: Start with the introductory paragraphs to understand the goal: "intelligent routing of inference requests based on Service Level Objectives (SLOs) using latency predictions." How it Works: This is the most important section. It outlines a four-step process: SLO extraction, latency prediction, headroom calculation, and pod selection. Understand that headroom (SLO minus predicted latency) is the key decision metric. A negative headroom means the SLO is likely to be violated. Request Headers: Note the specific headers used to communicate SLOs to the gateway: x-slo-ttft-ms and x-slo-tpot-ms. This is how the client or application specifies its performance requirements for a given request. Headroom Selection Strategies: Skim this section. Strategies like least (tight packing) versus most (conservative) are classic load-balancing choices you've likely encountered. Monitoring: Review the table of Prometheus metrics at the end. Metrics like inference_objective_request_predicted_ttft_seconds and inference_objective_request_ttft_slo_violation_total are exactly what an SRE would use to observe the system's behavior and validate that the routing logic is working correctly.

Synthesizing the Graceful Degradation Flow

Let's put all the pieces together to see how this works end-to-end.

Imagine a Kubernetes cluster with two model deployments (or InferencePools):

  • Pool A: Replicas of a large, powerful model (e.g., Llama-3-70B).
  • Pool B: Replicas of a smaller, faster model (e.g., Mistral-7B).

Here is the step-by-step flow for a single request:

  1. Request Arrives: A client sends a request for an interactive chat to the AI Gateway. The request includes the header: x-slo-ttft-ms: 500.
  2. SLO Extraction: The gateway's routing plugin parses the header and identifies the 500ms TTFT SLO.
  3. Latency Prediction: The system is under moderate load, and P99 latency for the large model in Pool A is climbing. The gateway's latency predictor sidecar uses the current state of all pods (e.g., KV cache utilization, queue depth) to make a prediction:
    • Predicted TTFT for a pod in Pool A: 750ms.
    • Predicted TTFT for a pod in Pool B: 150ms.
  4. Headroom Calculation: The gateway calculates the headroom for each option:
    • Pool A Headroom:
    • Pool B Headroom:
  5. Routing Decision (Graceful Degradation): The gateway sees that routing to the primary model in Pool A would result in a negative headroom, violating the SLO. It therefore disqualifies Pool A for this request. It sees that Pool B has ample positive headroom. The gateway routes the request to a replica of the smaller model in Pool B.
  6. Result: The user receives a response that meets the performance expectation (TTFT < 500ms), albeit from a less powerful model. The service has gracefully degraded quality to preserve responsiveness.

This proactive, per-request check prevents the system from becoming bogged down and ensures that interactive applications remain snappy even under load.

Conclusion

In this lesson, we elevated our reliability strategy from simple failure recovery to proactive, performance-driven graceful degradation. This is a hallmark of a mature, production-grade system and a key skill for an LLM Ops engineer.

Key Takeaways:

  • Graceful degradation in LLM services often involves trading response quality for speed by routing to a smaller, faster model.
  • This pattern is triggered not by errors, but by latency SLO violations. Monitoring P99 latency and TTFT is essential.
  • An intelligent gateway or routing layer is the component responsible for implementing this logic.
  • The core mechanism involves predicting latency for available model endpoints, comparing it against the request's SLO to calculate headroom, and routing to an endpoint that can meet the performance requirement.

In our next lesson, we will continue exploring graceful degradation by examining another strategy: returning a "system busy" response when the inference queue depth exceeds a critical threshold. This provides another tool for managing overload and maintaining system stability.

Can't find a good explanation? Sign up and we'll make it for you

Sign up