Limit cache size by default
kelunik opened this issue · comments
See amphp/cache#4.
The linked issue has been implemented, what's a good default cache size?
@amphp/dns Any suggestions?
Don't really know.
I think a LRU cache with size=256 should be really sufficient for most needs. That's not too large, but really not less than 99% of use cases will need.
If it's a LRU cache, it should be way bigger than 256. Memory is pretty cheap and the entries are pretty small, right?
Is there any problem with having a 64kB entry cache?
I meant 256 entries ;-), which, in PHP, will be around 80 KB, I guess. (if using an array as fundamental structure … an object could optimize it a bit, down to probably 30 KB)
Yes, it's LRU as implemented in amphp/cache#5. Entries should be pretty small. Keep in mind that one lookup usually creates two entires, one for A
and one for AAAA
.
I guess something like 4096 entries should be totally enough? But most applications probably need way less, because they either query the same domains over and over or query random domains.