This work is licensed under a Creative Commons Attribution 3.0 Unported License. http://creativecommons.org/licenses/by/3.0/legalcode
Thesis: Gratuitous unnecessary complexity exists within the Designate code, and in the operation of Designate as a service. Making Designate a producer-worker type of project will vastly simplify the development and operation, and align it more to the true nature of the service it provides (DNS).
designate-pool-manager does a reasonably good job at pushing Create/Delete changes out to nameservers, but the process gets a bit less shiny after that.
designate-zone-manager does a good job at executing periodic timers for the zones it manages. However:
designate-mdns is a DNS server written in Python. It works well for small amounts of traffic, but as traffic grows, we may realize that we need it to be more specialized, as a DNS server written in Python should be. The logic for sending NOTIFYs and polling of changes seems less likely to belong in mdns in the future. If those bits were removed, designate-mdns could be rewritten to make use of a better tool for the problem.
A change to the underlying architecture of executing actual work on DNS servers and the running of other tasks. Essentially, removing designate-pool-manager and designate-zone-manager, replacing them with designate-worker and designate-producer (names up for debate) and removing certain logic from designate-mdns. All of the actual “work” would be put in the scalable designate-worker process, which has work produced by the API/Central, and designate-producer. designate-mdns gets back to it’s roots, and only answers AXFRs. Callbacks over queues that don’t involve the API are eliminated, simplifying the code in all components that deal with DNS servers.
No changes to the API or Database are required, with minimal changes to designate-central.
To the end user, the results of this change would be relatively simple:
These are the services that would remain present:
Other necessary components:
Services/components that are no longer required:
The scope of designate-worker‘s duties are essentially any and all tasks that Designate needs to take action to perform. For example:
The service essentially exposes a vast RPCAPI that contains tasks.
An important difference to Designate’s current model is that all of these tasks do not call back. They are all fire-and-forget tasks that will be shoved on a queue and await worker action.
tasks are essentially functions, that given relatively simple input, make the desired income happen on either nameservers, or the Designate database.
The cache performs a similar function to the current pool manager cache now.
It will store state for each different type of task that a worker can use to decide if it needs to continue with a task received from the queue, or simply drop it and move on to the next task.
This varies by task, some are relatively simple, knowing whether to perform a zone update to a certain serial number is knowable by seeing the serial number of a zone on each target in a pool. For DNSSEC zone signing, a key would probably be placed to indicate that a certain worker was working on resigning a zone, as it’s a more long-running process.
In the absence of such a cache, each worker will act naive and try to complete each task it receives.
Each task will be idempotent, to the degree that it is possible.
As mentioned in the Cache section, to a certain degree, tasks could be able to know if they need to complete work based on information in the cache.
But they should also make an effort to not duplicate work, for instance, if it’s trying to delete a zone that’s already gone, it should interpret the zone being gone as a sign that the delete is successful and move on.
On the whole these tasks would simply be lifted from where they currently exist in the code, and wouldn’t change all that much.
A slight change might be that during the course of the task, we may recheck that the work that is being undertaken still needs to be done.
As an example: An API customer creates many recordsets very quickly. The work being dispatched to designate-worker processes would go to a lot of different places, and one of the first updates to actually reach a nameserver might contain all the changes necessary to bring the zone up-to-date. The other tasks being worked should check before they send their NOTIFY that the state is still behind, and check again after they’ve sent their NOTIFY, but before they’ve began polling, so that they can cut down on unnecessary work for themselves, and the nameservers.
You could get even smarter about the markers that you drop in a cache for these tasks. For example, on a zone update, you could drop a key in the cache of the nature zoneupdate-foo.com., and other if other zoneupdate tasks for the same zone see that key, they could know to throw away their job and move on.
The partioning of certain elements that Designate had previously disappears. The worker service will send DNS queries, it will do cpu-bound tasks, but it will be one place to scale. It should be possible to have an extremely robust Designate architecture by simply scaling these workers.
designate-mdns will have it’s entire RPCAPI transferred to designate-worker. This will vastly simplify the the amount of work it needs to do while it sits in the critical path of providing zone transfers to nameservers Designate manages.
As a side-note, this would make this service much easier to optimize, or even rewrite in a faster programming language.
designate-producer is the place where jobs that produce tasks that are outside of the normal path of API operations and operate on some kind of timer live.
The key difference to the zone-manager service, is that this service simply generates work to be done, rather than actually doing the work. designate-producer simply decides what needs to be done, and sends RPC messages on the queue to designate-worker to actually perform the work.
As we’ve grown Designate, we’ve seen the need for this grow vastly, and even more so in the future.
We could move the periodic_sync and periodic_recovery tasks from the Pool Manager to this service.
The periodic_sync and periodic_recovery tasks in the Pool Manager have been a constant struggle to maintain and get right. This is due to a lot of factors.
Making the generation of tasks by periodic processes the job of only one Designate component simplifies the architecture, and allows to solve the problems it presents one time, one way, and generally do one thing well.
This service would essentially be a group of timers that wake up on a cadence and create work to be put on the queue for designate-worker processes to pick up.
The overhead is relatively low here, as we’re not actually doing the work, but more just scheduling the work to be done. This way we can focus on the unexpectedly difficult problem of dividing up the production of work that these processes will put on the queue.
To explain more clearly, the biggest problem we have in this service is making it fault-tolerant, but not duplicating work for designate-worker processes to do. This was solved before by tooz using the zone shards in the Designate database in designate-zone-manager and it seems to work well.
designate-worker processes, as described above, will do a certain amount of optimization so that they don’t duplicate work. But if we generate too much cruft, those processes will be bogged down just by the task of seeing if they need to do work. So we should work to minimize the amount of duplicate work we produce.
One potential complication of this implementation is that, as the number of timers and tasks that are out of Designate’s critical path of implementation grow, they may get in the way of designate-worker processes doing the tasks that are most important, namely CRUD of zones and records.
We propose having queues/exchanges for each type of task, this would be an optimal way to monitor the health of different types of tasks, and isolate the sometimes long-running tasks that periodic timers will produce from the relatively quicker, and more important CRUD operations. The algorithm for choosing tasks from the various options could be customized by a particular process if desired. But a good general default would be to handle CRUD operations from designate-central first. Or use a weighted random choice algorithm, with the critical-path CRUD operations having higher weights.
Upgrading to the next release with this change would introduce some operational changes. Mostly around the services that need to be deployed. The deployment need not be a cutover, deploying Newton Designate will work with or without the worker. This is because of a variety of compatibility measures taken:
The process for upgrading to the worker model code, after deploying Newton could look something like this: