[bind10-dev] recursor cache requirements - input required

Likun Zhang zlkzhy at gmail.com
Tue Dec 7 08:55:20 UTC 2010


Hi all,

I wrote one requirement document about recursor cache, see the link:
http://bind10.isc.org/wiki/RecursorCacheRequirements

I also copied the content of the document to this email(see below), so that
you can give some comments easily.

Welcome your comments!

Thanks
Likun


----------------------------------------------------------------------------
---------------------------------------------------------


= Recursor Cache - Requirements =

== Introduction ==
When seeing dns query statistics of recursor, only a small part of domain
names are queried frequently, so if the information of these domain names
are cached properly, it will accelerate the performance of recursor.

The base unit of recursor cache should be dns message. When the recursor get
the query results, the results are stored in the cache for a period of time
determined in the configuration of the domain name record in message. Next
time, when the recursor get one query, instead of sending query out to some
authritative server, the query result(if it exists and doesn't expire) in
the cache can be answered to the end-user directly.

Since dns messages in cache may share common rrsets, to decrease the memory
usage of dns message cache, it's better to add one rrset cache. messages in
cache just includes the rrset index information, different messages in
message cache will share the same rrset cache. See the below sketch. 

{{{
   |----------|----------|-------|
   | dns-msg1 | dns-msg2 |  ...  |  Message Cache
   |----------|----------|-------|
      \        /   |    \
       \      /    |     \
        \    /     |      \
      |--------|--------|-------|
      | rrset1 | rrset2 |  ...  |  RRset Cache
      |--------|--------|-------|
}}}

The cached data should can be dumped out, loaded from one file, and edited
in runtime.      
Recursor cache is the key component of recursor. This document outlines the
broad requirement of recursor cache.

== Requirements ==

=== RRset cache ===

The key for one rrset in cache should be "Domain_name + Type + Class". In
the value part, besides of the rdata of each rr in the rrset, there should
be rrset's signature(rrsig record), if it has, and the security
status(dnssec validation result) of rrset.


The expiration time for rrsets in cache should be "now + TTL", once one
rrset expires, it should never be used again.

Once the recursor get a new query result, the rrsets in the query result
should be used to update the rrset cache.

==== Looking up rrset ====
It must be possible to look up a rrset in the rrset cache:
 * If the rrset exists, return the information of rrset.
 * If the rrset doesn't exist, return NULL.

==== Adding rrset ====
 * If the rrset doesn't exist, the rrset should be inserted into the cache.
 * If the rrset exist, update rrset according the new value.

==== Deleting rrset ====
The interface for removing one rrset from the cache should be provided,
since it may be used by some third-part tools which can edit the rrset cache
directly.

==== Updating one rrset ====
The interface for updating one rrset should be provided. Note: some rrsets
in the cache may be updated before they expire.

==== dumping/loading to/from one document/database ====
The content of rrset cache should can be dumped to one document/database, so
that the rrset cache can be reused when the recursor is restarted.
Extra rrset expire time should be added when dumping, so that expired rrsets
can be ignored when loading rrset cache from the document/database.

=== Message Cache ===
The key for one message in the cache should be "Query_name + Query_type +
Query_Class", and expiration time for the message should be "now + TTL(The
lowerest TTL of rrsets in the message)". 

the value for one message should include message header, index information
for each rrset in different message sections. For the structure, see the
following sketch. The security status(dnssec validation result) of the
message should also be noted.

Once one message in cache expires, it should never be used again, then the
cache user should send out the query to some authorative server, update the
message cache when get the query result. rrset cache should be updated
together with message cache.

{{{
   |------------------------|
   |  	                    |  Messsage Header
   |------------------------|
   |  dname1 + type + class |
   |  dname2 + type + class |  Message Answer 
   |  ....                  |
   |------------------------| 
   |  dname1 + type + class |
   |  dname2 + type + class |  Message Authority 
   |  ....                  |
   |------------------------| 
   |  dname1 + type + class |
   |  dname2 + type + class |  Message Additional
   |  ....                  |
   |------------------------| 
}}}

==== Looking up message ====
It must be possible to look up a message in the message cache. 
 * If the message doesn't exist, return NULL.
 * If the message exists and doesn't expire, then lookup message's rrsets in
rrset cache. If one rrset expires or doesn't exist in rrset cache, return
NULL, or else, generate one real reply dns message and return it.
 * If the message exists and expires, return NULL.

==== Adding message ====
The interface for adding messages to the cache should be provided. When one
message is added, the rrsets in it should be used to update the rrset cache,
or inserted if it doesn't exist in the cache.

==== Deleting message ====
The interface for removing message from the cache should be provided.

==== dumping/loading to/from file ====
The content of message cache should can be dumped to one document/database,
so that the message cache can be reused when the recursor is restarted.
Extra message expire time should be added when dumping, so that expired
messages can be ignored when loading message cache from the
document/database.
Note: rrset cache should be loaded first.

== Miscellaneous ==
 * The rrset/message cache must be thread-safe.

 * The rrset/message cache size should be configurable.

 * LRU(Leatest Recently Used) entry in rrset/message cache should be removed
when cache size get close to the configured value.






More information about the bind10-dev mailing list