From 950e6b920d29d6976eee81eaf49044cfbc7c6462 Mon Sep 17 00:00:00 2001 From: jiangyongfeng <1219415757@qq.com> Date: Wed, 11 Dec 2019 13:44:43 +0800 Subject: [PATCH] doc: add FAQ about a/b test (#957) --- FAQ.md | 39 +++++++++++++++++++++++++++++++++++++++ FAQ_CN.md | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/FAQ.md b/FAQ.md index 8d60128ca853..e1bd1ec2e054 100644 --- a/FAQ.md +++ b/FAQ.md @@ -70,3 +70,42 @@ For the first problem, you can use https_proxy or use the `--server` option to s Run the `luarocks config rocks_servers` command(this command is supported after luarocks 3.0) to see which server are available. If using a proxy doesn't solve this problem, you can add `--verbose` option during installation to see exactly how slow it is. Excluding the first case, only the second that the `git` protocol is blocked. Then we can run `git config --global url."https://".insteadOf git://` to using the 'HTTPS' protocol instead of `git`. + +## How to support A/B testing via APISIX? + +An example, if you want to group by the request param `arg_id`: + +1. Group A:arg_id <= 1000 +2. Group B:arg_id > 1000 + +here is the way: +```json +curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -X PUT -d ' +{ + "uri": "/index.html", + "vars": [ + {"arg_id", "<=", "1000"} + ] + "plugins": { + "redirect": { + "uri": "/test?group_id=1" + } + } +}' + +curl -i http://127.0.0.1:9080/apisix/admin/routes/2 -X PUT -d ' +{ + "uri": "/index.html", + "vars": [ + {"arg_id", ">", "1000"} + ] + "plugins": { + "redirect": { + "uri": "/test?group_id=2" + } + } +}' +``` + +Here is the operator list of current `lua-resty-radixtree`: +https://github.com/iresty/lua-resty-radixtree#operator-list diff --git a/FAQ_CN.md b/FAQ_CN.md index 97cd1020d9c7..2f3ffece0c5c 100644 --- a/FAQ_CN.md +++ b/FAQ_CN.md @@ -72,3 +72,42 @@ luarocks 服务。 运行 `luarocks config rocks_servers` 命令(这个命令 如果使用代理仍然解决不了这个问题,那可以在安装的过程中添加 `--verbose` 选项来查看具体是慢在什么地方。排除前面的 第一种情况,只可能是第二种,`git` 协议被封。这个时候可以执行 `git config --global url."https://".insteadOf git://` 命令使用 `https` 协议替代。 + +## 如何通过APISIX支持A/B测试? + +比如,根据入参`arg_id`分组: + +1. A组:arg_id <= 1000 +2. B组:arg_id > 1000 + +可以这么做: +```json +curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -X PUT -d ' +{ + "uri": "/index.html", + "vars": [ + {"arg_id", "<=", "1000"} + ] + "plugins": { + "redirect": { + "uri": "/test?group_id=1" + } + } +}' + +curl -i http://127.0.0.1:9080/apisix/admin/routes/2 -X PUT -d ' +{ + "uri": "/index.html", + "vars": [ + {"arg_id", ">", "1000"} + ] + "plugins": { + "redirect": { + "uri": "/test?group_id=2" + } + } +}' +``` + +更多的 lua-resty-radixtree 匹配操作,可查看操作列表: +https://github.com/iresty/lua-resty-radixtree#operator-list