facebook/tornado — pull request #626 by gabtremblay (2012-11-06 03:02:22+00:00)
Title: CachedResolver

Added a new resolver that avoids to hit socket.getaddrinfo for each request.

This resolver adds a fair speed increase in Single-Host multi-request code where the dns server is slow or rate-limited. It also gives a noticeable performance increase and network noise decrease when doing 1k+ requests on the same host.

Cache timeout can be controlled with expire_minutes constructor params.

I had to fix the netutil_test.py since socket.getaddrinfo returns IPPROTO_TCP as the protocol on linux and IPPROTO_IP under windows. Tested both platforms.

Supplementary notes: If you are to compare the speed of both resolver, don't forget to add force_instance=True to your constructor since tornado will re-use the previous instance.