-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Current State
The official example of proxy-mirror do not preserve connections, the example will create new connection for every new mirror request, which is not suitable for scenarios with high traffic. Another problem is, we can not mirror the traffic to multiple servers.
curl http://127.0.0.1:9180/apisix/admin/routes/1 \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"plugins": {
"proxy-mirror": {
"host": "http://127.0.0.1:9797"
}
},
"upstream": {
"nodes": {
"127.0.0.1:1999": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}'
reference: https://github.com/apache/apisix/blob/master/docs/zh/latest/plugins/proxy-mirror.md
Desired State
I want to add a section about how to use proxy-mirror with nginx's upstream. as an example, use the following config for proxy-mirror plugin:
curl http://127.0.0.1:9180/apisix/admin/routes/1 \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"plugins": {
"proxy-mirror": {
"host": "http://mirror-upstream"
}
},
"upstream": {
"nodes": {
"127.0.0.1:1999": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}'
and define the upstream in config.yaml:
apisix:
node_listen: 8080 # APISIX listening port
enable_heartbeat: true
enable_admin: true
# skip some content......
http_configuration_snippet: |
# the upstream is used by proxy-mirror.
upstream mirror-upstream {
server 127.0.0.1:7979 fail_timeout=1s max_fails=1;
keepalive 100;
keepalive_requests 1000;
keepalive_timeout 60s;
}
# skip some content......
proxy-mirror:
timeout: # avoid waiting for the request to be processed by the proxy-mirror
connect: 100ms
read: 100ms
send: 100msIn this way, proxy-mirror will reuse the connection pool maintained by nginx upstream, and with upstream, we can mirror the traffic into multiple servers too.
I want to ask the official's suggestion, whether you are willing to accept contents of this type, and what requirements there are.
related:
Metadata
Metadata
Assignees
Labels
Type
Projects
Status