Skip to content

Commit

Permalink
doc: perf test for memory consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed Jul 12, 2024
1 parent 37cf30d commit 48994bc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions kong/dns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Table of Contents
* [new](#new)
* [resolve](#resolve)
* [resolve_address](#resolve_address)
* [Performance characteristics](#performance-characteristics)
* [Memory](#memory)

# APIs

Expand Down Expand Up @@ -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 = <domain>, ttl = 3600, class = 1, type = 1}`.
* Domain: ~36 bytes string, e.g., `example<n>.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)
2 changes: 1 addition & 1 deletion kong/templates/nginx_kong.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/shared_dict.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 48994bc

Please sign in to comment.