diff --git a/kong/dns/README.md b/kong/dns/README.md index b77fc735acb5..8597627bda23 100644 --- a/kong/dns/README.md +++ b/kong/dns/README.md @@ -11,6 +11,8 @@ Table of Contents * [new](#new) * [resolve](#resolve) * [resolve_address](#resolve_address) +* [Performance characteristics](#performance-characteristics) + * [Memory](#memory) # APIs @@ -138,3 +140,35 @@ When calling multiple times on cached records, it will apply load-balancing base * control whether to solely retrieve data from the internal cache without querying to the nameserver. [Back to TOC](#table-of-contents) + +# Performance characteristics + +## Memory + +We evaluated the capacity of DNS records using the following resources: + +* Shared memory size: + * 5 MB (by default): `lua_shared_dict kong_dns_cache 5m`. + * 10 MB: `lua_shared_dict kong_dns_cache 10m`. +* DNS response: + * Each DNS resolution response contains some number of A type records. + * Record: ~80 bytes json string, e.g., `{address = "127.0.0.1", name = , ttl = 3600, class = 1, type = 1}`. + * Domain: ~36 bytes string, e.g., `example.long.long.long.long.test`. Domain names with lengths between 10 and 36 bytes yield similar results. + +The results of ) are as follows: + +| shared memory size | number of records per response | number of loaded responses | +|--------------------|-------------------|----------| +| 5 MB | 1 | 20224 | +| 5 MB | 2 ~ 3 | 10081 | +| 5 MB | 4 ~ 9 | 5041 | +| 5 MB | 10 ~ 20 | 5041 | +| 5 MB | 21 ~ 32 | 1261 | +| 10 MB | 1 | 40704 | +| 10 MB | 2 ~ 3 | 20321 | +| 10 MB | 4 ~ 9 | 10161 | +| 10 MB | 10 ~ 20 | 5081 | +| 10 MB | 20 ~ 32 | 2541 | + + +[Back to TOC](#table-of-contents) diff --git a/kong/templates/nginx_kong.lua b/kong/templates/nginx_kong.lua index af8035350b24..c42868b2139e 100644 --- a/kong/templates/nginx_kong.lua +++ b/kong/templates/nginx_kong.lua @@ -24,7 +24,7 @@ lua_shared_dict kong_db_cache_miss 12m; lua_shared_dict kong_secrets 5m; > if not legacy_dns_client then -lua_shared_dict kong_dns_cache 12m; +lua_shared_dict kong_dns_cache 5m; > end underscores_in_headers on; diff --git a/spec/fixtures/shared_dict.lua b/spec/fixtures/shared_dict.lua index 17ab30ba0b6f..fe0691d0a138 100644 --- a/spec/fixtures/shared_dict.lua +++ b/spec/fixtures/shared_dict.lua @@ -13,7 +13,7 @@ local dicts = { "kong_db_cache_2 16m", "kong_db_cache_miss 12m", "kong_db_cache_miss_2 12m", - "kong_dns_cache 12m", + "kong_dns_cache 5m", "kong_mock_upstream_loggers 10m", "kong_secrets 5m", "test_vault 5m",