> For the complete documentation index, see [llms.txt](https://yangsx95.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yangsx95.gitbook.io/notes/distributed/yi-zhi-xing/fu-zhi/nacos-distro-xie-yi.md).

# Nacos Distro协议

Distro是阿里巴巴的私有协议，目前流行的Nacos服务管理框架就采用了Distro协议。Distro 协议被定位为 **临时数据的一致性协议** ：该类型协议， **不需要把数据存储到磁盘或者数据库 ，因为临时数据通常和服务器保持一个session会话， 该会话只要存在，数据就不会丢失** 。

Distro 协议保证写必须永远是成功的，即使可能会发生网络分区。当网络恢复时，把各数据分片的数据进行合并。

Distro 协议具有以下特点：

* 专门为了注册中心而创造出的协议；
* 客户端与服务端有两个重要的交互，服务注册与心跳发送；
* 客户端以服务为维度向服务端注册，注册后每隔一段时间向服务端发送一次心跳，**心跳包需要带上注册服务的全部信息**，在客户端看来，服务端节点对等，所以请求的节点是随机的；
* 客户端请求失败则换一个节点重新发送请求；
* 服务端节点都存储所有数据，但每个节点只负责其中一部分服务，在接收到客户端的“写”（注册、心跳、下线等）请求后，服务端节点判断请求的服务是否为自己负责，如果是，则处理，否则交由负责的节点处理；
* 每个服务端节点主动发送健康检查到其他节点，响应的节点被该节点视为健康节点；
* 服务端在接收到客户端的服务心跳后，如果该服务不存在，则将该心跳请求当做注册请求来处理；
* 服务端如果长时间未收到客户端心跳，则下线该服务；
* 负责的节点在接收到服务注册、服务心跳等写请求后将数据写入后即返回，后台异步地将数据同步给其他节点；
* 节点在收到读请求后直接从本机获取后返回，无论数据是否为最新。


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yangsx95.gitbook.io/notes/distributed/yi-zhi-xing/fu-zhi/nacos-distro-xie-yi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
