02-mixed-recursive-authority-setup 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. Mixed recursive & authoritative setup
  2. =====================================
  3. Ideally we will run the authoritative server independently of the
  4. recursive resolver.
  5. We need a way to run both an authoritative and a recursive resolver on
  6. a single platform, listening on the same IP/port. But we need a way to
  7. run only one of them as well.
  8. This is mostly the same problem as we have with DDNS packets and xfr-out
  9. requests, but they aren't that performance sensitive as auth & resolver.
  10. There are a number of possible approaches to this:
  11. One fat module
  12. --------------
  13. With some build system or dynamic linker tricks, we create three modules:
  14. * Stand-alone auth
  15. * Stand-alone resolver
  16. * Compound module containing both
  17. The user then chooses either one stand alone module, or the compound one,
  18. depending on the requirements.
  19. Advantages
  20. ~~~~~~~~~~
  21. * It is easier to switch between processing and ask authoritative questions
  22. from within the resolver processing.
  23. Disadvantages
  24. ~~~~~~~~~~~~~
  25. * The code is not separated (one bugs takes down both, admin can't see which
  26. one takes how much CPU).
  27. * Bind 9 does this and bind 9 code is a jungle. Maybe it's not just a
  28. coincidence.
  29. * Limits flexibility -- for example, we can't then decide to make the resolver
  30. threaded (or we would have to make sure the auth processing doesn't break
  31. with threads, which will be hard).
  32. There's also the idea of putting the auth into a loadable library and the
  33. resolver could load and use it somehow. But the advantages and disadvantages
  34. are probably the same.
  35. Auth first
  36. ----------
  37. We do the same as with xfrout and ddns. When a query comes, it is examined and
  38. if the `RD` bit is set, it is forwarded to the resolver.
  39. Advantages
  40. ~~~~~~~~~~
  41. * Separate auth and resolver modules
  42. * Minimal changes to auth
  43. * No slowdown on the auth side
  44. Disadvantages
  45. ~~~~~~~~~~~~~
  46. * Counter-intuitive asymetric design
  47. * Possible slowdown on the resolver side
  48. * Resolver needs to know both modes (for running stand-alone too)
  49. There's also the possibility of the reverse -- resolver first. It may make
  50. more sense for performance (the more usual scenario would probably be a
  51. high-load resolver with just few low-volume authoritative zones). On the other
  52. hand, auth already has some forwarding tricks.
  53. Auth with cache
  54. ---------------
  55. This is mostly the same as ``Auth first'', however, the cache is in the auth
  56. server. If it is in the cache, it is answered right away. If not, it is then
  57. forwarded to the resolver. The resolver then updates the cache too.
  58. Advantages
  59. ~~~~~~~~~~
  60. * Probably a good performance
  61. Disadvantages
  62. ~~~~~~~~~~~~~
  63. * Cache duplication (several auth modules, it doesn't feel like it would work
  64. with shared memory without locking).
  65. * Cache is probably very different from authoritative zones, it would
  66. complicate auth processing.
  67. * The resolver needs own copy of cache (to be able to get partial results),
  68. probably a different one than the auth server.
  69. Receptionist
  70. ------------
  71. One module does only the listening. It doesn't process the queries itself, it
  72. only looks into them and forwards them to the processing modules.
  73. Advantages
  74. ~~~~~~~~~~
  75. * Clean design with separated modules
  76. * Easy to run modules stand-alone
  77. * Allows for solving the xfrout & ddns forwarding without auth running
  78. * Allows for views (different auths with different configurations)
  79. * Allows balancing/clustering across multiple machines
  80. * Easy to create new modules for different kinds of DNS handling and share
  81. port with them too
  82. Disadvantages
  83. ~~~~~~~~~~~~~
  84. * Need to set up another module (not a problem if we have inter-module
  85. dependencies in b10-init)
  86. * Possible performance impact
  87. Implementation ideas
  88. ~~~~~~~~~~~~~~~~~~~~
  89. * Let's have a new TCP transport, where we send not only the DNS messages,
  90. but also the source and destination ports and addresses (two reasons --
  91. ACLs in target module and not keeping state in the receptionist). It would
  92. allow for transfer of a batch of messages at once, to save some calls to
  93. kernel (like a length of block of messages, it is read at once, then they
  94. are all parsed one by one, the whole block of answers is sent back).
  95. * A module creates a listening socket (UNIX by default) on startup and
  96. contacts all the receptionists. It sends ACL match for the packets to send
  97. to the module and the address of the UNIX socket. All the receptionists
  98. connect to the module. This allows for auto-configuring the receptionist.
  99. * The queries are sent from the receptionist in batches, the answers are sent
  100. back to the receptionist in batches too.
  101. * It is possible to fine-tune and use OS-specific tricks (like epoll or
  102. sending multiple UDP messages by single call to sendmmsg).