You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2020/10/31 09:40:16 UTC

[apisix] branch master updated: Update FAQ_CN.md (#2582)

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

juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 5efeca0  Update FAQ_CN.md (#2582)
5efeca0 is described below

commit 5efeca07b835df66a5d37c8e22a7d960a28d476d
Author: HelloBug0 <73...@users.noreply.github.com>
AuthorDate: Sat Oct 31 17:40:07 2020 +0800

    Update FAQ_CN.md (#2582)
---
 FAQ_CN.md | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/FAQ_CN.md b/FAQ_CN.md
index 77f1d0e..7b20a35 100644
--- a/FAQ_CN.md
+++ b/FAQ_CN.md
@@ -247,3 +247,22 @@ apisix reload
     ```
 
 2.重启抑或 reload APISIX
+
+## APISIX利用etcd如何实现毫秒级别的配置同步
+etcd提供接口wait、waitdir接口用于监听指定关键字、目录是否发生变更,如果发生变更,返回更新的数据。
+
+以waitdir接口为例:
+`syntax: res, err = cli:waitdir(dir:string [, modified_index:uint [, timeout:uint] ])`
+其中timeout参数表示调用进程和etcd长连接的时间,值为0时表示无长连接。
+
+APISIX关于etcd长连接时间的配置如下:
+```
+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
+```
+APISIX使用waitdir接口监视目录的变更,timeout默认配置为30秒,即APISIX调用进程和etcd保持30秒的长连接。
+
+若APISIX进程调用该函数时,监听的目录没有更新,函数直接返回,长连接保持,调用进程可处理其他事件。30秒内有数据更新,etcd通过该函数返回更新结果,调用进程处理更新数据,30秒内无数据返回,到达超时时间30秒时,etcd通过该函数返回一条超时消息,调用进程处理超时信息,然后再次调用waitdir函数监听指定目录。APISIX通过以上过程实现配置的实时更新。