Repository navigation
feat(request_forwarder): Add config option to set DNS cache TTL - #312
Merged
Merged
Conversation
ketiltrout
requested review from
aelanman,
andrerenard,
ljgray,
rikvl and
tristpinsm
September 28, 2026 23:40
This was referenced Sep 28, 2026
Open
ljgray
approved these changes
Sep 29, 2026
Adds an optional config parameter "dns_cache_ttl" to allow changing the AIOHTTP DNS caching time. The default TTL in coco is 10 seconds, which is also AIOHTTP's default value for this parameter. There's a bigger change here, though: * previoiusly coco would create a new connector (which is the object containing the DNS cache) for each endpoint forward. This connector would last until the end of a single endpoint forward at which point it would be closed and the cache deleted. Theoretically, the DNS cache could have been used if an endpoint had multiple forwards to the same host but, in practice, that's not how our endpoints usually work. (Typically a given endpoint forwards only once to a particular host.) The upshot is, in old coco, the DNS cache was essentially unused. * To fix this, the connector is now cached in the RequestForwarder itself and reused over-and-over again. I think this should be fine, but it will need some field testing to see if there's unintended consequences. If "dns_cache_ttl" is set to zero, DNS caching will be explicitly disabled in the request forwarder, which (due to the above) is effectively the legacy behaviour.
ketiltrout
force-pushed
the
dvw/dns_caching
branch
from
October 2, 2026 00:23
98c2c2b to
72bd97a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional config parameter "dns_cache_ttl" to allow changing the AIOHTTP DNS caching time. The default TTL in coco is 10 seconds, which is also AIOHTTP's default value for this parameter.
There's a bigger change here, though:
If "dns_cache_ttl" is set to zero, DNS caching will be explicitly disabled in the request forwarder, which (due to the above) is effectively the legacy behaviour.
Also, merged the
RequestForwarder.set_session_limitfunction intoRequestForwarder.__init__since it was only ever called immediately after creating the request forwarder. If there was a reason to have these separate in the past, that's no longer the case.A re-implementation of #243 now that the test-suite works again.