Operations 11 min read

How to Implement Service Degradation for High Availability

This article explains the concept of service degradation, why it is needed to maximize limited resources during traffic spikes, outlines common degradation strategies, and provides practical steps and code examples for ranking, sequencing, and implementing degradation in both front‑end and back‑end systems.

Programmer DD
Programmer DD
Programmer DD
How to Implement Service Degradation for High Availability

What is Degradation

Degradation aims to maximize limited resource efficiency by sacrificing non‑core functions when a system is under heavy load.

z has three items to buy: A (3000), B (700), C (1200). With only 3000, he should choose A.

According to the 80/20 principle, 20% of functions generate 80% of value, while the remaining 20% require 80% of resources.

In e‑commerce peak periods, conversion is the priority; features like comments or pagination can be temporarily disabled to free resources for ordering.

Typical Degradation Forms

Sacrifice user experience: disable pagination, add captchas, tighten query conditions, replace dynamic data with static data, or show a temporary closure page.

Sacrifice functional completeness: turn off defensive features such as risk control, skip validation checks, or reduce log levels to error/fault only.

Sacrifice timeliness: relax real‑time requirements (e.g., show "In Stock" instead of exact count), delay asynchronous tasks, or lower update frequency.

How to Do Degradation

Two main steps: ranking and sequencing, then implementation.

Ranking and Sequencing

Assign each feature a level (1 highest, 5 lowest). When pressure rises, drop lower‑level features first. Use a sequence number to break ties, possibly based on how many upstream functions a component supports. Ensure a component’s downstream dependencies are not assigned a lower level than the component itself.

Implementation

Define trigger conditions (error rate, latency, resource usage). When triggered, code checks the current run level and index to decide whether to enter degradation mode.

int _runLevel = 3; // default system level
int _runIndex = 7; // default sequence
if (myLevel > _runLevel && myIndex > _runIndex) {
    // enter degradation mode
} else {
    // normal processing
}

Front‑end approaches: set Cache‑Control headers, skip asynchronous data loading, disable buttons, or serve static pages via reverse proxy.

Back‑end approaches for read operations: return mock data or throw exceptions; for write operations: make persistence asynchronous, reduce consistency requirements, or disable writes in the data‑access layer.

if (writeDatabase(data) == true) {
    if (writeDistributedCache(data) == true) {
        writeLocalCache(data);
        return success;
    } else {
        rollbackDatabase(data);
        return fail;
    }
} else {
    return fail;
}

During high load, downgrade consistency by making persistence asynchronous, e.g., push a message to MQ and return success.

if (writeDistributedCache(data) == true) {
    writeLocalCache(data);
    pushMessage(data); // async via MQ or disk
    return success;
} else {
    return fail;
}

Summary

Degradation requires careful ranking, sequencing, and simple implementation; the number of possible combinations grows factorially, and traffic patterns change, so continuous tuning and adjustment are essential.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Operationshigh availabilitySystem Designdegradation
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.