[Unbound-users] Uneven distribution of queries between threads/processes

Attila Nagy bra at fsn.hu
Wed Feb 15 09:26:34 UTC 2012


Hi,

On 02/13/12 09:50, W.C.A. Wijngaards wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Attila,
>
> On 02/12/2012 05:39 PM, Attila Nagy wrote:
>> Hi,
>>
>> Not a new thing, and likely it's how the OS (FreeBSD) works -if
>> the listening socket is shared between threads and processes-, but
>> the number of queries are very unevenly distributed between
>> unbound threads/processes.
>>
>> For a threaded unbound currently the QPSs are: thread0: 1.45k
>> thread1: 2.72k thread2: 3.97k
>>
>> and for a multiprocess unbound: thread0: 1.16k thread1: 3.05k
>> thread2: 2.34k
>>
>> Is it possible to make it more balanced on the application side?
> Very interesting.  I assume you have a quadcore, or a tricore :-)
>
> Unbound simply listens to the port 53 socket.  There is nothing else
> it can do I think?  Unless there are some secret socket options that
> make FreeBSD do something like load-spreading?
>
> If you want to force this issue, you could create firewall/pf rules
> that rewrite incoming packets to three other port numbers (1053, 1054,
> 1055) and start unbound three times on port 1053, 1054, 1055.  Make
> sure you also rewrite the UDP replies back to sourceport 53.  In this
> case, then, I can do something on the software side, instead of
> forcing you to run 3x unbound, some sort of option that makes unbound
> have every process listen to its own port number could be create.  But
> this approach may be useless, perhaps the system does not do load
> spreading because this queryamount (8k) is too low (it has a max of
> 300k?).
>
Well, I haven't read all the code, instead I ask.
Unbound comm_point_create_udp_ancil sets the callback, which I assume is 
called when a new activity happens on the listening socket.
But who does this load balancing in a multi-threaded environment in this 
specific case?
FreeBSD's kqueue, by having multiple entities (threads, their callbacks) 
on the notification list? libev, which subscribes once and handles the 
threads?
Or the socket code?




More information about the Unbound-users mailing list