From 2c1b2adb5cdccb185ca1657048088eb1fe800c65 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 6d77e84fac05..6d6349a28546 100644 --- a/kong.conf.default +++ b/kong.conf.default @@ -1507,7 +1507,7 @@ G# ----------------------- # 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. @@ -1515,6 +1515,8 @@ G# ----------------------- # 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 bf8a58336991..9af35670f7ec 100644 --- a/kong/templates/kong_defaults.lua +++ b/kong/templates/kong_defaults.lua @@ -158,7 +158,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