Skip to content

Instantly share code, notes, and snippets.

@abh
Created February 22, 2012 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abh/1885657 to your computer and use it in GitHub Desktop.
Save abh/1885657 to your computer and use it in GitHub Desktop.
ndns vs native-dns/node-dns benchmark
# using dnsperf from http://www.nominum.com/resources/measurement-tools
echo =======
echo native-dns
echo =======
dnsperf -d test.data -l 8 -p 5302
echo =======
echo ndns
echo =======
dnsperf -d test.data -l 8 -p 15353
/* on my test box I get about ~220/qps with this */
"use strict";
var dns = require('../dns'),
server = dns.createServer('udp4');
server.bind(15353);
server.on('request', function (request, response) {
//console.log(request)
response.answer.push(dns.A({
name: request.question[0].name,
address: '127.0.0.1',
ttl: 600,
}));
response.answer.push(dns.A({
name: request.question[0].name,
address: '127.0.0.2',
ttl: 600,
}));
response.send();
});
server.on('error', function (err, buff, req, res) {
console.log(err.stack);
});
/* this code gets about 3200qps on my test box */
var sys = require('sys'), puts = sys.puts;
var dgram = require('dgram');
var ndns = require('../lib/ndns');
var server = ndns.createServer('udp4');
var client = ndns.createClient('udp4');
var BIND_PORT = 5302;
server.on("request", function(req, res) {
res.setHeader(req.header);
for (var i = 0; i < req.q.length; i++)
res.addQuestion(req.q[i]);
if (req.q.length > 0) {
var name = req.q[0].name;
if (name == ".")
name = "";
res.header.qr = 1;
res.header.ra = 1;
res.header.rd = 0;
res.header.ancount = 3;
res.header.nscount = 4;
res.header.arcount = 5;
res.addRR(name, 2, "IN", "A", "127.0.0.2");
res.addRR(name, 2, "IN", "A", "127.0.0.3");
}
res.send();
});
server.bind(BIND_PORT);
foo.pgeodns A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment