> For the complete documentation index, see [llms.txt](https://tarscloud.gitbook.io/tarsdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tarscloud.gitbook.io/tarsdocs/qi-ye-ban-ben-jie-shao/tars-iplist.md).

# IP-LIST级联缓存机制

在开源版本设计中, ip list是通过业务服务定时刷新tarsregistry来获取的, 但是这种方式存在以下问题:

* 业务服务需要定时刷新, 会给tarsregistry带来较大的压力
* 实时性不高, 一般都配置的60秒触发一次;
* 负载均衡无法做得更加实时, 比如添加或减小服务, 需要等待60秒才能生效, 如果要做无损发布, 则需要每发布一个服务都要等待>60s;

当然这种模式下, 由于客户端会自动屏蔽出问题的服务, 因此对业务调用影响不大, 但是如果能够更实时的刷新ip list会更有效的实现服务的负载均衡.

为了更有效的实现ip list的实时刷新, 建立了tarsregistry服务的数据级联机制.

## tarsregistry 数据级联机制

tarsregistry的数据级联机制即tarsnode和tarsregistry服务可以级联起来, 实时同步tarsregistry的所有关于ip list解析相关的数据, 实现机制如下:

* tarsregistry提供注册接口, 用于tarsnode注册到tarsregistry, 同步数据
* 每类数据都有时间戳, 用于判断是否需要更新;
* tarsnode定时上报心跳, 如果时间戳不一致, 则更新全量数据;
* 服务端角度, 只有obj数据和节点数据是增量更新机制变, 其他数据量较小, 一旦变更则全量推送
* 对于tarsregistry, obj数据如果是delete行为, 会全量加载, 并判断是否有变化, 根据变化通知下游

## ip list刷新机制变更

* tarsnode拥有tarsregistry全量的数据, 并且几乎实时的同步tarsregistry的数据;
* 业务服务的访问某服务时获取的ip list从tarsnode中获取;
* 业务服务可以更加密集的刷新ip list(比如3秒), 不会给tarsregistry带来更大的压力;


---

# 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, and the optional `goal` query parameter:

```
GET https://tarscloud.gitbook.io/tarsdocs/qi-ye-ban-ben-jie-shao/tars-iplist.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
