Hello guys! For the last couple of weeks I've been working on "dynamic zones" for NSD, which at the moment means MySQL backend with simple cache (or "zones dictionary", if you prefer) to avoid "zone matching" via database queries. --- HOW IT WORKS? --- Upon receiving query (class IN or ANY) new code checks in cache if there is matching zone in MySQL database. If it finds one then all records for that zone are imported from MySQL database, parsed, checked and then whole zone is injected into regular NSD workflow instead of NSD's database. After reply is sent, zone is discarded from memory. "Soft-fail" approach is used for parsing and checking, which means that error in single record doesn't discard whole zone and as long as SOA record is imported properly, zone will be injected into NSD. Cache is updated periodically (at the same time when BIND8 stats are generated or every 60s if NSD was compiled without this feature). --- PERFORMANCE --- Test machine: Intel Atom 1.6Ghz running OpenBSD 4.5 and MySQL 5.0.77. -------------------------------- | daemon | queries / second | | version | 1child | 2childs | -------------------------------- | nsd-3.2.1 | 16326 | 3501 | | nsd-dz | 1029 | 1148 | | nsd-dz* | 3175 | 4066 | -------------------------------- *MySQL with query cache enabled. This can be easily improved with local cache (with short expire time) of already generated zones, but at this time I'm not really sure if it's even needed. --- HOW TO INSTALL? --- $ wget http://www.nlnetlabs.nl/downloads/nsd/nsd-3.2.1.tar.gz $ wget http://labs.frickle.com/files/nsd-dz-0.2.patch.gz $ tar zxf nsd-3.2.1.tar.gz $ gunzip nsd-dz-0.2.patch.gz $ patch -d nsd-3.2.1 < nsd-dz-0.2.patch $ ./configure --enable-checking --enable-dz $ make && make install --- DATABASE CONFIGURATION --- CREATE DATABASE nsd; USE nsd; CREATE TABLE zones ( zone_id INT UNSIGNED AUTO_INCREMENT, origin VARCHAR(255) NOT NULL, PRIMARY KEY (zone_id), UNIQUE (zone) ) ENGINE = InnoDB; CREATE TABLE records ( record_id INT UNSIGNED AUTO_INCREMENT, zone_id INT UNSIGNED NOT NULL, owner VARCHAR(255) NOT NULL, ttl INT UNSIGNED NOT NULL, type VARCHAR(10) NOT NULL, rdata VARCHAR(255) NOT NULL, PRIMARY KEY (record_id), FOREIGN KEY (zone_id) REFERENCES zones(zone_id) ON DELETE CASCADE ) ENGINE = InnoDB; GRANT SELECT ON nsd.* TO 'nsd'@'localhost' IDENTIFIED BY 'nsd'; If you want to use different database / username / password, then please edit MYSQL_* in dz.h before compilation. --- THE END --- At the moment this patch completely ignores zone transfers (but I believe that in such setup they should be done via MySQL replication anyway) and it supports only few most popular RR types (A, AAAA, CNAME, DNAME, MX, NS, SOA, SRV, TXT). This is still work in progress, so I'd really appreciate any feedback. Best regards, Piotr Sikora < piotr.sikora at frickle.com >