tjfontaine / node-dns

Replacement dns module in pure javascript for node.js
MIT License
585 stars 153 forks source link

Server Performance is slow #8

Closed abh closed 12 years ago

abh commented 12 years ago

In a simple test the ndns server implementation is about an order of magnitude faster than native-dns/node-dns. :-/

(I've been looking into redoing the pgeodns server in javascript with node, but it won't work if it doesn't end up being at least as fast as the Perl version).

tjfontaine commented 12 years ago

I haven't done any real profiling around this yet, it wasn't that it was designed to be slow just that I wanted to get feature complete before I started trying to make things fast.

I especially want to have a test suite up before I start mucking with things, which I should have just had in the first place.

If you do some profiling don't hesitate to add numbers here.

abh commented 12 years ago

I made a gist with my test scripts: https://gist.github.com/1885657

tjfontaine commented 12 years ago

Ah, dnsperf will be a nice tool for this sort of thing :)

tjfontaine commented 12 years ago

Ok, the dnsperf data is a bit depressing, my linux box was getting 430qps to start. I pushed a commit that removed the dependency on my other module pystruct and that bumped things to 520qps, but that was just the easiest pass I could do quickly.

It seems like my object model is what is getting in the way here, I have some thoughts about how to simplify such that field definitions are only getting created at startup which I think should solve the majority of the performance issue.

Ideally I want to get to the point where Buffer is the major bottleneck, which would mean my code isn't really getting in the way.

abh commented 12 years ago

Glad you're looking into it! That being said, I don't think it's unreasonable to just declare that performance beyond a reasonable minimum for clients and "toy servers" or "internal utility servers" isn't in the scope for the project. I would like it to be super fast; but it's possible that for 99.24% of everyone else it doesn't matter at all.

A couple hundred requests a second is plenty for most servers – even my custom DNS servers have an average QPS in that ballpark, it's just that they have spikes half a dozen times a day with many times more. :-/

tjfontaine commented 12 years ago

Ok the majority of this is fixed in 28b1497, thanks for giving me the motivation to fix it! It also considerably speeds up client resolution as well. My dnsperf tests are now coming in around 2000qps, so a considerable improvement. Thanks