> For the complete documentation index, see [llms.txt](https://www.axisnow.io/zh/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.axisnow.io/zh/docs/edge/endpoints/origin-address/health-check.md).

# 健康检查

真实流量监测与主动探测如何判定剔除和恢复

健康检查的主体是源地址里的每个地址，判断在每个边缘上独立进行：一个地址在某个边缘上被剔除，不影响其他边缘。两种信号各有阈值，共同驱动同一个地址状态；状态由负载均衡在分配请求时查询。

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-5d70f11a83107c517cd9126a85a64c22d7eca48b%2Forigin-health-check-flow.png?alt=media" alt="真实流量监测和主动 TCP 探测各自计数，达到阈值即剔除该地址；剔除期间负载均衡不分配请求，剔除时长到期自动恢复，探测连续成功可提前恢复源地址级剔除、持续失败则保持剔除；全部地址被剔除时回退到第一个地址"><figcaption></figcaption></figure>

## 两种信号 <a href="#signals" id="signals"></a>

<table data-search="false"><thead><tr><th width="140">信号</th><th>来源</th><th>判定</th><th width="150">默认</th></tr></thead><tbody><tr><td>真实流量监测</td><td>每一次回源失败，含重试中的失败尝试：连接失败、超时，以及 502 Bad Gateway、504 Gateway Timeout 响应</td><td>一个地址从第一次失败起的时间窗内累计失败达到次数即剔除。没有流量就没有判断</td><td>始终开启，120 秒内 10 次</td></tr><tr><td>主动 TCP 探测</td><td>边缘每 10 秒向地址的探测端口建立一次 TCP 连接，单次超时 10 秒</td><td>连续失败 3 次剔除，连续成功 3 次恢复</td><td>关闭，端口 443</td></tr></tbody></table>

真实流量监测只计失败、不计成功。源站返回 500 Internal Server Error、503 Service Unavailable 和 4xx 不计入，这类响应说明源站可达，是否算故障由业务决定。

主动探测由回源流量触发：某个边缘把请求分配给某个地址时，才为该地址建立探测任务，对该地址的最后一次回源后约 30 分钟任务过期，探测停止。地址被剔除后不再被分配，探测最多再持续约 30 分钟，之后退回按剔除时长到期恢复。没有流量的源地址不会被探测，也不会产生健康事件。

## 剔除与恢复 <a href="#ejection" id="ejection"></a>

* **剔除**：任一信号达到阈值，地址在该边缘上进入剔除状态，负载均衡在剔除时长内不再把请求分配给它，重试时也跳过。
* **到期恢复**：剔除时长（默认 60 秒，1–3600）到期后地址自动回到可用状态，流量立即恢复。真实流量监测没有恢复判定：源站仍未恢复时，流量回来后再次累计到阈值，再次剔除，事件里表现为反复的剔除记录。
* **探测恢复**：开启主动探测后，剔除期间探测继续进行。连续成功达到次数即提前恢复；持续失败则在到期前再次判定剔除，地址保持不可用，直到探测连续成功。真实流量中的连接失败同样打断连续成功的计数。探测只作用于源地址级状态，由 502、504 或读取超时触发的域级剔除不受探测影响，只在剔除时长到期后恢复。
* **不切断流量**：一个源地址的全部地址在某个边缘上都被剔除时，请求回退到第一个地址继续回源，由回源重试处理失败。源地址不做整体熔断，恢复由后续请求直接观察。

## 计数的范围 <a href="#scope" id="scope"></a>

源地址常常是一个网关或反向代理，后面还有多个业务后端。连接失败说明源地址本身不可达，与具体域无关；502、504 响应可能只是某个后端的问题。失败按两级计数：

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-24ac9e466b0f00dad828c81a320e0ad4459a2f30%2Forigin-health-check-scope.png?alt=media" alt="三个域引用同一个源地址：连接失败在源地址级计数，三个域共享，剔除对三者同时生效；全部失败（含连接失败）按域计数，只影响该域对该地址的回源"><figcaption></figcaption></figure>

* **源地址级**：连接未建立的失败（拒绝、连接超时、TLS 握手失败）和主动探测的结果。所有引用该源地址的域共享计数与剔除。
* **域级**：全部失败，含连接失败、读取超时和 502、504。按引用的域和回源端口分别计数，剔除只对该域的回源生效。

两级状态同时查询，任一级剔除即不分配。TCP 转发端点没有状态码，以连接失败或连接后未收到任何数据为失败：连接失败两级计数，未收到数据只在域级计数。

## 事件 <a href="#events" id="events"></a>

剔除和恢复各记一条健康检查事件，带边缘、地址、信号来源和阈值，在[源地址洞察](/zh/docs/edge/endpoints/origin-address/insight.md#events)中查看。真实流量监测只产生剔除事件，恢复事件只来自主动探测。源站未恢复而反复剔除时，每次剔除都记一条。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.axisnow.io/zh/docs/edge/endpoints/origin-address/health-check.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
