apisix icon indicating copy to clipboard operation
apisix copied to clipboard

feat: make dns resolution answers TTL configurable

Open darkSheep404 opened this issue 1 year ago • 3 comments

Description

we using upstream config in yml like that

upstreams:
  - id: app
    name: app
    pass_host: node
    nodes:
      "app.test.com": 1
    scheme: https

currently app.test.com point to 2 instance A (ip : 1.1.1) ,B (ip: 2.2.2) if A down, app.test.com will auto point to B(ip: 2.2.2) when using nginx we can use below code to let nginx refresh ip of app.test.com every 10 seconds to ensure get the lastest ip

location /lst-dns-test/ {
   resolver 6.6.6.6  valid=10s;   # 6.6.6.6 is a dns server
   set $proxy_url "app.test.com";
   proxy_pass http://$proxy_url;
}

can we do this in apisix for below upstream ?

upstreams:
  - id: app
    name: app
    pass_host: node
    nodes:
      "app.test.com": 1
    scheme: https

Environment

  • APISIX version 3.2 LTS

darkSheep404 avatar Apr 01 '24 09:04 darkSheep404

https://apisix.apache.org/docs/apisix/discovery/dns/ Does this help you?

hanqingwu avatar Apr 02 '24 02:04 hanqingwu

https://apisix.apache.org/docs/apisix/discovery/dns/ Does this help you?

thanks for your help but seems this config can only let upstreams use a dns server, can not set valid=10s; to keep refresh to get lastest ip ?

darkSheep404 avatar Apr 02 '24 06:04 darkSheep404

yes, I think dns resolve is realtime , no cache valid for 10s .

hanqingwu avatar Apr 02 '24 06:04 hanqingwu