Re: Name resolution limits
Re: Name resolution limits
- Subject: Re: Name resolution limits
- From: Bryan Christianson <email@hidden>
- Date: Sat, 9 Feb 2002 11:36:29 +1300
At 10:25 AM -0800 2/8/02, Becky Willrich wrote:
I'm always surprised by the answers on this topic (and every time
I'm checking my code for the safety of my mind).
Name resolution with up to 10 Threads (pool of potential and
reusable Threads) using the Cocoa APIs is working fine.
No performance issue.
I don't want to be the bearer or bad news, but this is not true.
The Cocoa APIs go through gethostbyname, same as everyone else; this
is the API bottleneck for host resolution. It is possible that the
Cocoa APIs are sufficiently aggressive with caching that they can
appear timely in all but the most perverse cases; I don't know. It
is also possible the Cocoa APIs take care of the thread-safety
issues by locking, but that won't change the fact that host lookups
are serialized, so the total time is still going to be O(n), where n
is the number of requests.
If you want to talk to lookupd to do your host resolution, and want
to do it in anything resembling a maintainable fashion, you must
ultimately call gethostbyname. gethostbyname on all public releases
of MacOS X and Darwin is not threadsafe, not re-entrant, and blocks
for up to 75 seconds if a server is unresponsive.
Here are the workarounds I know of:
A workaround I have used in the past is to write a small helper
program that does the lookup (via res_search() cause I wanted the
ttls for smart caching) and then fork off multiple copies of this
program from the requestor, using unix sockets that re-map stdin,
stdout etc. As you do each lookup you then round robin calls to each
helper and can have multiple queries running in parallel.
This technique, coupled with name caching, worked very well for a
real-time traffic monitor looking at our network backbone (i.e.
hundred of customers browsing the web with thousands of IP addresses
being resolved.
I've posted the source of the helper and the caller/cache at
http://cora.whatroute.net:81/dnshelper if any one is interested. This
code has only ever been compiled under Linux, but it should be pretty
easy to port to darwin.
--
Bryan Christianson
email: <
mailto:email@hidden>
Home Page: <
http://crash.ihug.co.nz/~bryanc>
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.