-
Notifications
You must be signed in to change notification settings - Fork 883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dnsdist: Random load-balancing of incoming queries on reuseport sockets #13399
base: master
Are you sure you want to change the base?
Conversation
When `SO_ATTACH_REUSEPORT_EBPF` is available (Linux >= 4.6) along with `BPF_FUNC_get_prandom_u32()` (Linux >= 4.1), this implements a fully random load-balancing policy between incoming sockets in the same `reuseport` group (listening address and port, `reuseport` set). This is needed because Linux implements `reuseport` load-balancing based on (source IP, source port, destination IP, destination port, protocol), which means that if all queries comes from the same IP and port, and to the same IP and port, they will be distributed to a single worker only, using a single CPU core.
Pull Request Test Coverage Report for Build 6572957075
💛 - Coveralls |
{ | ||
#if defined(HAVE_BPF_FUNC_get_prandom_u32) && defined(SO_ATTACH_REUSEPORT_EBPF) | ||
const struct bpf_insn randomReusePortPolicy[] = { | ||
#include "random-reuseport-policy.ebpf" |
Check notice
Code scanning / CodeQL
Include header files only Note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Says who?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Says who?
AV Rule 32, Joint Strike Fighter Air Vehicle C++ Coding Standards. Lockheed Martin Corporation, 2005.
IMO, this would be a valuable function to have in the recursor. |
Short description
When
SO_ATTACH_REUSEPORT_EBPF
is available (Linux >= 4.6) along withBPF_FUNC_get_prandom_u32()
(Linux >= 4.1), this implements a fully random load-balancing policy between incoming sockets in the samereuseport
group (listening address and port,reuseport
set). This is needed because Linux implementsreuseport
load-balancing based on (source IP, source port, destination IP, destination port, protocol), which means that if all queries comes from the same IP and port, and to the same IP and port, they will be distributed to a single worker only, using a single CPU core.This is a draft pull request to get feedback (@wojas). The current eBPF code is very simple, and is not optimized for NUMA nodes or even just to keep the queries on the local CPU cores, which would be possible. @omoerbeek, @Habbie, if you are interested in using that code in the authoritative server and/or the recursor I'll refactor the eBPF loading code to make it possible.
Note that it is actually possible to replace the eBPF policy from an external program at runtime, but then we need to find a way to let the program know how many sockets we have, and perhaps our CPU affinity. eBPF maps could probably be used to do that.
Related to #8033 and #13327.
Checklist
I have: