You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by me...@apache.org on 2020/11/25 06:30:13 UTC

[apisix] branch membphis/doc-faq-cn created (now e315cb9)

This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch membphis/doc-faq-cn
in repository https://gitbox.apache.org/repos/asf/apisix.git.


      at e315cb9  doc(faq):  uses etcd to implement millisecond configuration sync

This branch includes the following new commits:

     new e315cb9  doc(faq):  uses etcd to implement millisecond configuration sync

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[apisix] 01/01: doc(faq): uses etcd to implement millisecond configuration sync

Posted by me...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch membphis/doc-faq-cn
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit e315cb9da241549368736d3224f38df1602c7325
Author: YuanSheng Wang <me...@gmail.com>
AuthorDate: Wed Nov 25 14:30:04 2020 +0800

    doc(faq):  uses etcd to implement millisecond configuration sync
---
 FAQ_CN.md | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/FAQ_CN.md b/FAQ_CN.md
index 66587d1..3423324 100644
--- a/FAQ_CN.md
+++ b/FAQ_CN.md
@@ -240,21 +240,23 @@ Apache APISIX 的插件支持热加载。
 
 2.重启抑或 reload APISIX
 
-## APISIX利用etcd如何实现毫秒级别的配置同步
-etcd提供接口wait、waitdir接口用于监听指定关键字、目录是否发生变更,如果发生变更,返回更新的数据。
+## APISIX 利用 etcd 如何实现毫秒级别的配置同步
+
+etcd 提供订阅接口用于监听指定关键字、目录是否发生变更(比如: [watch](https://github.com/api7/lua-resty-etcd/blob/master/api_v3.md#watch)、[watchdir](https://github.com/api7/lua-resty-etcd/blob/master/api_v3.md#watchdir))。
 
-以waitdir接口为例:
-`syntax: res, err = cli:waitdir(dir:string [, modified_index:uint [, timeout:uint] ])`
-其中timeout参数表示调用进程和etcd长连接的时间。
 
-APISIX关于etcd长连接时间的配置如下:
 ```
+# APISIX 关于 etcd 的配置如下(conf/config.yaml):
 etcd:
-  host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.
-    - "http://127.0.0.1:2379"     # multiple etcd address
-  prefix: "/apisix"               # apisix configurations prefix
-  timeout: 30                     # 30 seconds
+  host:                           
+    - "http://127.0.0.1:2379"     
+  prefix: "/apisix"               
+  timeout: 30                     # 30 seconds timeout
 ```
-APISIX使用waitdir接口监视目录的变更,timeout默认配置为30秒,即APISIX调用进程和etcd保持30秒的长连接。
 
-若APISIX进程调用该函数时,监听的目录没有更新,函数直接返回,长连接保持,调用进程可处理其他事件。30秒内有数据更新,etcd通过该函数返回更新结果,调用进程处理更新数据,30秒内无数据返回,到达超时时间30秒时,etcd通过该函数返回一条超时消息,调用进程处理超时信息,然后再次调用waitdir函数监听指定目录。APISIX通过以上过程实现配置的实时更新。
+APISIX 主要使用 `etcd.watchdir` 接口监视目录的变更,默认超时时间为 30 秒。
+
+APISIX 调用函数 `etcd.watchdir`:
+
+* 如果监听的目录没有数据更新,该调用会被阻塞,直到超时或其他错误返回。
+* 如果监听的目录有数据更新,etcd 将立刻返回订阅到的新数据,APISIX 将它更新到内存缓存。借助 etcd 增量通知毫秒级特性,APISIX 也就完成了毫秒级的配置同步。