Skip to content

FreeRTOS+TCP should cache more than one DNS result IP address #58

@gkwicker

Description

@gkwicker

FreeRTOS+TCP currently caches only a single DNS result IP address when ipconfigUSE_DNS_CACHE == 1. This doesn't work well with load balanced services where DNS returns a list of addresses for use – see AWS Route 53 FAQ as one example. As described in that FAQ, "IP addresses associated with load balancers can change at any time due to scaling up, scaling down, or software updates.". Because it can take time for DNS to update, sometimes the IP address cached by FreeRTOS+TCP will not be valid. For most clients, this is not an issue. For example in Linux, gethostbyname() returns all of the IP addresses associated with the hostname in a struct hostent structure. If a client can't connect to one of the IP addresses, it can simply retry with the next one in the list. However, in FreeRTOS+TCP if the single address stored in the cache is not valid, the application will be unable to connect to the service until the TTL expires and a new DNS query is sent.

Example DNS lookup of load-balanced service – FreeRTOS+TCP should allow the DNS result cache to be configured such that it contains multiple IP addresses per host, and applications should be able to cycle through these addresses if it can't connect to one of them.

$ nslookup xxxxxxxxxxxxxx-ats.iot.us-west-2.amazonaws.com
Server:		xxx.xxx.xxx.xxx
Address:	xxx.xxx.xxx.xxx#53

Non-authoritative answer:
Name:	xxxxxxxxxxxxxx-ats.iot.us-west-2.amazonaws.com
Address: 52.4x.xxx.xxx
Name:	xxxxxxxxxxxxxx-ats.iot.us-west-2.amazonaws.com
Address: 52.2x.xxx.xxx
Name:	xxxxxxxxxxxxxx-ats.iot.us-west-2.amazonaws.com
Address: 52.1x.xxx.xxx
Name:	xxxxxxxxxxxxxx-ats.iot.us-west-2.amazonaws.com
Address: 34.2xx.xxx.xxx
Name:	xxxxxxxxxxxxxx-ats.iot.us-west-2.amazonaws.com
Address: 52.3x.xx.xxx
Name:	xxxxxxxxxxxxxx-ats.iot.us-west-2.amazonaws.com
Address: 44.2xx.xx.xxx

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions