流量镜像时防止重复写入 API 调用
Prevent repeat write API calls whilst traffic mirroring
我正在考虑将流量镜像与 Istio 一起用于暗测试版本。
镜像流量将意味着写入 API,如订单和付款等被多次调用,我不希望这样,否则我将向客户收取两次费用并向他们发送重复的产品。
是否有标准的方法来防止这种情况(在生产中存根似乎是一件奇怪的事情)或者镜像仅适用于读取 API?
问题
有 diagram 的流量镜像设置。
尽管这些镜像请求被镜像为“fire and forget”并且来自镜像服务的回复只是(由 envoy 代理 sidecar)丢弃到 /dev/null 而没有返回给调用者,它是还在用这个 api.
解决方案
如评论所述
在我看来,您应该为测试目的添加一些路径 custom header,这样这只能由您或您的组织进行测试,而客户不应参与其中。
Christian Posta here 详细描述了这个主题。
When we deploy a new version of our service and mirror traffic to the test cluster, we need to be mindful of impact on the rest of the environment. Our service will typically need to collaborate with other services (query for data, update data, etc). This may not be a problem if the collaboration with other services is simply reads or GET requests and those collaborators are able to take on additional load. But if our services mutates data in our collaborators, we need to make sure those calls get directed to test doubles and not the real production traffic.
您可以考虑几种方法,所有这些方法都在上面的 link 中进行了描述:
- 停止某些测试配置文件的协作服务
- 综合交易
- 虚拟化测试集群的数据库
- 具体化测试集群的数据库
In practice, mirroring production traffic to our test cluster (whether that cluster exists in production or in non-production environments) is a very powerful way to reduce the risk of new deployments. Big webops companies like Twitter and Amazon have been doing this for years. There are some challenges that come along with this approach, but there exist decent solutions as discussed in the patterns above.
我正在考虑将流量镜像与 Istio 一起用于暗测试版本。
镜像流量将意味着写入 API,如订单和付款等被多次调用,我不希望这样,否则我将向客户收取两次费用并向他们发送重复的产品。
是否有标准的方法来防止这种情况(在生产中存根似乎是一件奇怪的事情)或者镜像仅适用于读取 API?
问题
有 diagram 的流量镜像设置。
尽管这些镜像请求被镜像为“fire and forget”并且来自镜像服务的回复只是(由 envoy 代理 sidecar)丢弃到 /dev/null 而没有返回给调用者,它是还在用这个 api.
解决方案
如评论所述
在我看来,您应该为测试目的添加一些路径 custom header,这样这只能由您或您的组织进行测试,而客户不应参与其中。
Christian Posta here 详细描述了这个主题。
When we deploy a new version of our service and mirror traffic to the test cluster, we need to be mindful of impact on the rest of the environment. Our service will typically need to collaborate with other services (query for data, update data, etc). This may not be a problem if the collaboration with other services is simply reads or GET requests and those collaborators are able to take on additional load. But if our services mutates data in our collaborators, we need to make sure those calls get directed to test doubles and not the real production traffic.
您可以考虑几种方法,所有这些方法都在上面的 link 中进行了描述:
- 停止某些测试配置文件的协作服务
- 综合交易
- 虚拟化测试集群的数据库
- 具体化测试集群的数据库
In practice, mirroring production traffic to our test cluster (whether that cluster exists in production or in non-production environments) is a very powerful way to reduce the risk of new deployments. Big webops companies like Twitter and Amazon have been doing this for years. There are some challenges that come along with this approach, but there exist decent solutions as discussed in the patterns above.