Skip to content

Perf issue with c-ares DNS resolver #34812

@nicoche

Description

@nicoche

Hi 👋

Title: Perf issue with c-ares DNS resolver

Description:

The c-ares DNS resolver calls getifaddrs syscall. getifaddrs can be slow or CPU intensive (example #19717). If Envoy has many DNS clusters, the performance hit can be considerable.

Repro steps:

This issue happened for us with the following scenario:

  • A server runs latest Envoy version
  • The server has 700+ network namespaces
  • XDS server tries to push between 500 and 2k DNS clusters onto Envoy

As a result, after connecting to the XDS server, the main thread is saturated initializing c-ares DNS resolvers. For us, it causes high CPU usage and disconnection-reconnection loops to the XDS server, probably because the main thread is busy listing interfaces instead of responding to keep-alives.

Root cause:

Because there are many network namespaces on our server, getifaddrs is CPU intensive.

image

It seems that c-ares DNS resolver lists the network interfaces of the machine to satisfy filter_unroutable_families https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/network/dns_resolver/cares/v3/cares_dns_resolver.proto#extensions-network-dns-resolver-cares-v3-caresdnsresolverconfig:

(bool) The resolver will query available network interfaces and determine if there are no available interfaces for a given IP family. It will then filter these addresses from the results it presents. e.g., if there are no available IPv4 network interfaces, the resolver will not provide IPv4 addresses.

Suggestion:

No matter the value of filter_unroutable_families, interfaces are listed anyway. I would suggest to:

Other ideas welcome. I'm happy to provide a PR too

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/dnsenhancementFeature requests. Not bugs or questions.no stalebotDisables stalebot from closing an issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions