]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: resolvers: hash the records before inserting them into the tree
authorWilly Tarreau <w@1wt.eu>
Thu, 21 Oct 2021 06:18:01 +0000 (08:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 21 Oct 2021 06:29:02 +0000 (08:29 +0200)
commitdcb696cd31d9c58a84705c74930f12c952b52874
tree747838372c3490fd3087088207c587000a1c5be0
parent7893ae117f2d367e0b2aee286a5eee980497c2d8
MEDIUM: resolvers: hash the records before inserting them into the tree

We're using an XXH32() on the record to insert it into or look it up from
the tree. This way we don't change the rest of the code, the comparisons
are still made on all fields and the next node is visited on mismatch. This
also allows to continue to use roundrobin between identical nodes.

Just doing this is sufficient to see the CPU usage go down from ~60-70% to
4% at ~2k DNS requests per second for farm with 300 servers. A larger
config with 12 backends of 2000 servers each shows ~8-9% CPU for 6-10000
DNS requests per second.

It would probably be possible to go further with multiple levels of indexing
but it's not worth it, and it's important to remember that tree nodes take
space (the struct answer_list went back from 576 to 600 bytes).
src/resolvers.c