[
https://issues.apache.org/jira/browse/JAMES-2698?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16813649#comment-16813649
]
Amichai Rothman commented on JAMES-2698:
----------------------------------------
Thanks for taking the time to look into this.
For starters, of course there should be a single consistent and documented API
and implementation, as the current state is confusing and wasteful. No argument
there.
I haven't looked further at the code, but I assume resolving all the hosts from
the MX records is used not only for logging, but also for contacting the hosts
in order to send outgoing messages... it's possible that this is done in
another part of the code, and the DNS cache is filled by these iterator calls
first. If it's just for logging, then certainly there's no reason to do all
these lookups always. At the very least it should consider the appropriate log
level configuration, or do this only if there is an error that will later need
to be diagnosed. DNS lookups are quite expensive when it comes to performance
(as is any network round-trip that is not really needed), so should be used
with care.
In any case, whatever the next API is going to be, the implementation will
likely get refactored or copied around from this one, so I would suggest to
leave this issue open until the desired implementation is finalized to make
sure it does not carry over these unnecessary performance penalties, and that
all the considerations in this discussion are taken into account.
> MXHostAddressIterator performance
> ---------------------------------
>
> Key: JAMES-2698
> URL: https://issues.apache.org/jira/browse/JAMES-2698
> Project: James Server
> Issue Type: Bug
> Components: DNSServer
> Affects Versions: 3.4.0
> Reporter: Amichai Rothman
> Priority: Minor
>
> In the old implementation (James 2.3.x) of iterating over the MX records and
> resolving their hosts, e.g. used by MailetContext.getSMTPHostAddresses(), it
> purposely did the lookups lazily, i.e. the hosts for each record were looked
> up only when it was reached by the iteration. The current implementation does
> all the lookups for all records up front and then returns them one by one.
> I don't know if there was a reason for this change or if it was introduced by
> mistake, but it seems reasonable that since these hosts are used to try and
> send messages to the domain, and once it succeeds there is usually no need to
> continue the iteration, that the old behavior would be much more efficient
> and trigger many fewer DNS lookups on average.
> If there is a good reason for the change, it should be documented in the
> iterator, otherwise please return the previous behavior.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]