You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/03/08 07:24:30 UTC

[GitHub] [apisix] Gerrard-YNWA commented on issue #6536: request help: Is there any way to set timeout for proxy-mirror plugin

Gerrard-YNWA commented on issue #6536:
URL: https://github.com/apache/apisix/issues/6536#issuecomment-1061483747


   > AFAIK, the responses to mirror subrequests are ignored. http://nginx.org/en/docs/http/ngx_http_mirror_module.html
   > 
   > Are you saying that the response to mirror requests slows down the response to normal requests?
   > 
   > Can you expand on how you verified this?
   
   @tzssangglass  We have refactored some api for backend server and using proxy-mirror plugin to copy the http traffic for consistency verification.
   When the new refactored api server's response slows down during the mirroring period, the next request on the same connection will stuck until the mirror sub-request ends.
   We have reproduced offline and confirmed via capturing the network package. Mirroring request to a slow backend indeed affects the response in a connection reused scenario.
   
   1. prepare two backend normal one listen 0.0.0.0:7000 and slow one (sleep 10s to simulate a slow response) on 0.0.0.0:7001.
   2. create route via apisix admin api
   ```
   curl "http://127.0.0.1:9080/apisix/admin/routes/1" -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" -X PUT -d '
   {
     "methods": ["GET"],
     "host": "172.16.20.83",
     "uri": "/*",
     "upstream": {
       "type": "roundrobin",
       "nodes": {
         "172.16.20.83:7000": 1
       }
     },
     "plugins": {
           "proxy-mirror": {
               "host": "http://172.16.20.83:7001",
               "sample_ratio": 1
           }
       }
   }'
   ```
   3. use `hey` create traffic to apisix
   ```
   hey -c 1 -n 2 "http://172.16.20.83:9080/foo"
   ```
   4. the captured network packets shows the second http response comes 10 seconds  after the request sending
   ![image](https://user-images.githubusercontent.com/9128069/157184886-6c643bad-139f-49fc-b9f5-fa1dbf73ddc6.png)
   
   
   
   > > when mirroring traffic to a slow backend, the next coming http request on the reused connection will stuck
   > 
   > This is the limitation of Nginx's mirror feature, as the main req could be ended only after subrequests.
   
   @spacewander Thanks, We now added the `proxy_connect_timeout`, `proxy_read_timeout` and `proxy_send_timeout` in the mirror location to a very short time as a workaround to reduce this side effect. Maybe this should be documented.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org