OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: poor ldap load distribution

From: Wietse Venema (wietseporcupine.org)
Date: Fri Jun 01 2007 - 13:46:53 CDT


Dan Lannom:
> I'm running postfix 2.4.0-2 on Debian Etch [backport] with ldap lookups
> for virtualaliases/relay_recipient. postfix-ldap is also version 2.4.0-2
> and ldap-utils is 2.3.30-5.
>
> I'm trying to use a round robin DNS entry to distribute the queries over
> multiple ldap servers, but for some reason they are all being redirected
> to the same system, which is pushing load too high.
>
> Ldapsearch against the same DNS entries exhibits the same behavior of
> all queries going to the same server. So it seems unlikely to be a
> postfix issue per-se.
>
>
> The current maps look like
>
> server_host = rrobin-dns.domain
> search_base = dc=searchbase
> query_filter =
> (&(|(mail=%s)(mailalternateaddress=%s))(maildeliveryoption=mailbox))
> result_attribute = maildrop
> bind=no
>
> and the queries from the DNS server return something like:
>
> Name: dns-a-record
> Addresses: ip1, ip2
> ..
> Name: dns-a-record
> Addresses: ip2, ip1
>
> in normal round-robin fashion
>
> Originally the ldap servers were on different subnets but moving them to
> the same subnet made no different.
>
> The server getting all the queries responds slightly faster due to a
> different configuration, but this is not trivial to change.
>
> Load does transfer to the 2nd system, if the 1rst system is disabled.
>
> Any suggestions?

I am not aware of any Postfix control over the order of host
selection. Postfix passes the LDAP server name to the ldap_init()
or ldap_initialize() function, and the LDAP library figures out
what host to connect to.

If your DNS server always returns the host list in the exact same
order, or if some nasty system routine always sorts the host list
into the same order, then the LDAP library will always try the
hosts in the same order.

This sounds like a job for an LD_PRELOAD shim that randomizes
multi-address results from gethostbyname() or from getaddrinfo().
How would one force such a shim between libldap and libc?

        Wietse