From 29d1844042774c58da378f33d7556cbf2da4d1a3 Mon Sep 17 00:00:00 2001 From: Xiaoch Date: Tue, 5 Dec 2023 17:51:05 +0800 Subject: [PATCH] feat(templates): bump `dns_stale_ttl` default to 1 hour (#12087) A longer stale TTL can help reduce the load on less performant/reliable DNS servers, reducing proxy latency and availability impact to Kong's proxy path. KAG-3080 Co-authored-by: Datong Sun --------- Co-authored-by: Datong Sun (cherry picked from commit 533d3f76177596dcb9b5911dec52eb2cfff9fdf7) --- changelog/unreleased/kong/bump_dns_stale_ttl.yml | 3 +++ kong.conf.default | 4 +++- kong/templates/kong_defaults.lua | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/kong/bump_dns_stale_ttl.yml diff --git a/changelog/unreleased/kong/bump_dns_stale_ttl.yml b/changelog/unreleased/kong/bump_dns_stale_ttl.yml new file mode 100644 index 000000000000..43ed55cb0795 --- /dev/null +++ b/changelog/unreleased/kong/bump_dns_stale_ttl.yml @@ -0,0 +1,3 @@ +message: Bump `dns_stale_ttl` default to 1 hour so stale DNS record can be used for longer time in case of resolver downtime. +type: performance +scope: Configuration diff --git a/kong.conf.default b/kong.conf.default index 94155faa8af9..87dad2196f3f 100644 --- a/kong.conf.default +++ b/kong.conf.default @@ -1560,7 +1560,7 @@ # property receives a value (in seconds), it # will override the TTL for all records. -#dns_stale_ttl = 4 # Defines, in seconds, how long a record will +#dns_stale_ttl = 3600 # Defines, in seconds, how long a record will # remain in cache past its TTL. This value # will be used while the new DNS record is # fetched in the background. @@ -1568,6 +1568,8 @@ # record until either the refresh query # completes, or the `dns_stale_ttl` number of # seconds have passed. + # This configuration enables Kong to be more + # resilient during resolver downtime. #dns_cache_size = 10000 # Defines the maximum allowed number of # DNS records stored in memory cache. diff --git a/kong/templates/kong_defaults.lua b/kong/templates/kong_defaults.lua index 0633fa2035da..fea900620be8 100644 --- a/kong/templates/kong_defaults.lua +++ b/kong/templates/kong_defaults.lua @@ -165,7 +165,7 @@ dns_resolver = NONE dns_hostsfile = /etc/hosts dns_order = LAST,SRV,A,CNAME dns_valid_ttl = NONE -dns_stale_ttl = 4 +dns_stale_ttl = 3600 dns_cache_size = 10000 dns_not_found_ttl = 30 dns_error_ttl = 1