cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: DNS cache size control

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 17 Apr 2002 14:55:25 +0200 (MET DST)

On Wed, 17 Apr 2002, Jacky Lam wrote:

> Is it possible to add some control on DNS cache size? Especially, the
> global one?

No, there's no current limit. This is badness.

They should probably be controlable per single-cache basis.

> I use global size and run through 150 websites and fnd that the dns cache
> size grow to more than 6M!!!

That is of course totally unacceptable.

> There are two reasons:
> i) Libcurl won't remove some old expired dns cache

Right. Stupid, really.

> ii) Libcurl will alloc 9000bytes to hold dns answer. However,
> normally, it just use 500-600bytes. (on Linux with gethostbyname_r).

When I wrote that function once upon the time, I used a set limit since I
thought it wasn't worth it trying different sizes (and some platforms can't
do that trick). Now, with the data being kept around for potentionly a long
while, it has of course changed the requirements of that function...

That 500-600 bytes is also a question about how many IP addresses that the
single name resolves to, right?

> I solve the second problem by using an adaptive buffer size which reduce
> the dns cache size to 1/10 of the original.

Sounds clever and good. Does it make a good fix for others to see too?

> For the first problem, I can only destroy all handles and call
> global_cleanup. Is there any alternative?

Not available right now, but we really need to address this...

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-04-17