# Understanding the Initial Access Count for SDS Exception Rate Limiting

> Learn how SDS exception rate limiting uses initial access count to avoid premature degradations and ensure statistically valid decisions before downgrading services.

- Repository: [DiDi/sds](https://github.com/didi/sds)
- Tags: deep-dive
- Published: 2026-02-28

---

**The initial access count (`exceptionRateStart`) in Didi’s SDS (Service Degradation System) serves as a statistical volume threshold that prevents exception-rate downgrade decisions until a minimum number of requests has been observed, safeguarding against noisy or premature degradations caused by statistically insignificant sample sizes.**

The `didi/sds` repository implements sophisticated circuit-breaking and degradation logic for high-traffic distributed systems. Within its exception-rate limiting mechanism, the **initial access count** plays a critical role in ensuring that downgrade triggers only activate once sufficient traffic volume guarantees statistical reliability.

## How the Initial Access Count Guards Against Noisy Degradation

The `exceptionRateStart` field in `SdsStrategy` defines the minimum request volume required before the system evaluates exception rates. According to the source code in [`ExceptionRateStrategyExecutor.java`](https://github.com/didi/sds/blob/main/ExceptionRateStrategyExecutor.java), the executor performs an early-return check that bypasses exception-rate calculations when the visit count remains below this threshold.

```java
if (strategy.getExceptionRateStart() == null || strategy.getExceptionRateStart() < 0 ||
    strategy.getExceptionRateThreshold() == null || strategy.getExceptionRateThreshold() < 0 ||
    strategy.getExceptionRateThreshold() > 100 ||
    strategy.getExceptionRateStart() >= checkData.getVisitCount()) {
    // Not enough traffic – skip exception‑rate check
    return true;
}

```

When `strategy.getExceptionRateStart() >= checkData.getVisitCount()` evaluates to `true`, the method returns `true`, indicating that the check passed and **no downgrade occurs**, even if the actual exception rate would otherwise exceed the threshold. This prevents scenarios where a single failure in ten requests (10% exception rate) triggers unnecessary degradation.

## Configuring the Initial Access Count

You can configure this safeguard via JSON configuration, programmatic API, or the SDS admin interface.

### JSON Strategy Configuration

Define the threshold in your strategy definition:

```json
{
  "point": "orderCreate",
  "exceptionRateThreshold": 15,
  "exceptionRateStart": 1000
}

```

This configuration ensures that SDS calculates exception rates only after collecting data from 1,000 requests, and triggers degradation only when the exception rate exceeds 15%.

### Programmatic Configuration

Instantiate and register the strategy directly in Java:

```java
SdsStrategy strategy = new SdsStrategy();
strategy.setPoint("orderCreate");
strategy.setExceptionRateThreshold(15);   // 15 %
strategy.setExceptionRateStart(1000L);    // require 1 000 requests first
SdsClient.getInstance().registerStrategy(strategy);

```

### Runtime Execution Flow

During request processing, SDS collects visit statistics in `CheckData`. The executor compares the current `visitCount` against `exceptionRateStart`:

```java
CheckData data = SdsClient.getInstance().getCheckData("orderCreate");

// If total visits < exceptionRateStart, the executor short‑circuits:
if (strategy.getExceptionRateStart() >= data.getVisitCount()) {
    // No exception‑rate downgrade, even if a few exceptions occurred
    return;
}

```

## Key Source Files and Components

The initial access count mechanism spans multiple components across the SDS client and admin modules:

- **[`SdsStrategy.java`](https://github.com/didi/sds/blob/main/SdsStrategy.java)** ([`sds-client/src/main/java/com/didiglobal/sds/client/bean/SdsStrategy.java`](https://github.com/didi/sds/blob/main/sds-client/src/main/java/com/didiglobal/sds/client/bean/SdsStrategy.java)): Defines the `exceptionRateStart` field and other strategy parameters.
- **[`ExceptionRateStrategyExecutor.java`](https://github.com/didi/sds/blob/main/ExceptionRateStrategyExecutor.java)** ([`sds-client/src/main/java/com/didiglobal/sds/client/strategy/executor/ExceptionRateStrategyExecutor.java`](https://github.com/didi/sds/blob/main/sds-client/src/main/java/com/didiglobal/sds/client/strategy/executor/ExceptionRateStrategyExecutor.java)): Implements the volume threshold validation and short-circuit logic.
- **[`PointStrategyDO.java`](https://github.com/didi/sds/blob/main/PointStrategyDO.java)** ([`sds-admin/src/main/java/com/didiglobal/sds/admin/dao/bean/PointStrategyDO.java`](https://github.com/didi/sds/blob/main/sds-admin/src/main/java/com/didiglobal/sds/admin/dao/bean/PointStrategyDO.java)): Persists the `exceptionRateStart` value in the administrative database.
- **[`PointStrategyRequest.java`](https://github.com/didi/sds/blob/main/PointStrategyRequest.java)** ([`sds-admin/src/main/java/com/didiglobal/sds/admin/controller/request/PointStrategyRequest.java`](https://github.com/didi/sds/blob/main/sds-admin/src/main/java/com/didiglobal/sds/admin/controller/request/PointStrategyRequest.java)): Receives the threshold configuration from admin UI requests.

## Summary

- The **initial access count** (`exceptionRateStart`) prevents premature exception-rate limiting by requiring a minimum sample size before evaluation.
- When visit counts fall below this threshold, `ExceptionRateStrategyExecutor` automatically returns `true`, allowing requests to proceed without downgrade checks.
- Configuration supports both declarative JSON/YAML definitions and programmatic Java APIs.
- This safeguard ensures statistically significant data before triggering service degradation decisions in high-traffic environments.

## Frequently Asked Questions

### What happens if the visit count is below the initial access threshold?

When `checkData.getVisitCount()` is less than `exceptionRateStart`, the `ExceptionRateStrategyExecutor` returns `true` immediately, treating the check as passed. This means the request proceeds normally without exception-rate downgrade evaluation, regardless of the current error rate.

### How does exceptionRateStart differ from exceptionRateThreshold?

**`exceptionRateStart`** defines the minimum number of requests required before calculating exception rates (statistical volume), while **`exceptionRateThreshold`** specifies the percentage of failed requests (0-100) that triggers degradation once sufficient volume exists.

### Where is the initial access count validated in the SDS codebase?

The validation logic resides in [`ExceptionRateStrategyExecutor.java`](https://github.com/didi/sds/blob/main/ExceptionRateStrategyExecutor.java) within the `sds-client` module. This executor compares the strategy's `exceptionRateStart` value against the runtime `visitCount` from `CheckData` before performing any exception-rate calculations.

### Can the initial access count be set to zero to disable the safeguard?

Yes, setting `exceptionRateStart` to `0` or `null` effectively disables the volume threshold, causing SDS to evaluate exception rates immediately. However, this risks noisy degradation decisions during low-traffic periods or service startup phases.