membphis commented on a change in pull request #2605:
URL: https://github.com/apache/apisix/pull/2605#discussion_r528731441
##########
File path: FAQ.md
##########
@@ -297,3 +297,27 @@ By default, APISIX only listens on port 9080 when handling
HTTP requests. If you
```
2. Reload or restart APISIX
+
+## How does APISIX use etcd to achieve millisecond-level configuration
synchronization
+
+Etcd provides interfaces `wait` and `waitdir` to monitor whether the specified
keywords and directories have changed, and return updated data if they have any
changes.
+
+Take the `waitdir` interface as an example:
+
+`syntax: res, err = cli:waitdir(dir:string [, modified_index:uint [,
timeout:uint] ])`
+
+The `timeout` parameter indicates the connection `timeout` seconds between the
calling process and etcd.
+
+APISIX configuration of etcd connection time is as follows:
+
+```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
+```
+
+APISIX uses the `waitdir` interface to monitor directory changes. The default
configuration of timeout is `30` seconds, so APISIX calling process maintains
keepalive connection with etcd for `30` seconds.
+
+If the listening directory is not updated when the APISIX process calls this
function, the function returns directly, the long connection is maintained, and
the calling process can handle other events. If there is data update within
`30` seconds, etcd returns the update result through this function, the calling
process handle updated data. If no data returned within `30` seconds, when the
timeout period reaches 30 seconds, etcd returns a timeout message through this
function, and the calling process handles timeout message, then calls the
waitdir function to monitor the specified directory again. APISIX realizes
real-time configuration updates through the above process.
Review comment:
`If the listening directory is not updated when the APISIX process calls
this function, the function returns directly`
I think this is wrong. I think you can submit a Chinese version first.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]