~ralph-bean/pylibravatar/tcp-dns

  • Committer: Ralph Bean
  • Date: 2015-06-26 18:25:23 UTC
  • Revision ID: rbean@redhat.com-20150626182523-a2vkfnft7fcvq902
Use tcp for SRV lookups.

By default, the DNS module is using udp.  I discovered this because it would
periodically time out on our server -- requests would sometimes take 30s that
would normally take less than 1s.  I'd like to use tcp for our use case in
order to avoid timeouts. However, that alone is not reason enough to ask
everyone else to use tcp.  They may want udp.  It is faster, right?

While playing with this, I found that on average tcp is repeatably faster than
udp for these kinds of requests.

See tcp:

  $ time python -c """
  import DNS
  DNS.DiscoverNameServers()
  [DNS.Request(name='_avatars._tcp.ralph.id.fedoraproject.org', qtype='SRV', protocol='tcp').req() for i in range(128)]
  """
  python -c   0.10s user 0.03s system 10% cpu 1.270 total

Versus udp:

  $ time python -c """
  import DNS
  DNS.DiscoverNameServers()
  [DNS.Request(name='_avatars._tcp.ralph.id.fedoraproject.org', qtype='SRV', protocol='udp').req() for i in range(128)]
  """
  python -c   0.24s user 0.11s system 3% cpu 9.514 total


Which makes it a more suitable default for libravatar.py, no?
Filename Latest Rev Last Changed Committer Comment Size
..
tests 9 12 years ago Francois Marier Add nose-based unit tests Diff
.bzrignore 1 12 years ago Francois Marier Initial version 14 bytes Diff Download File
Changelog.txt 36 10 years ago Francois Marier Bump changelog and version number for release 625 bytes Diff Download File
libravatar.py 39 8 years ago Ralph Bean Use tcp for SRV lookups. By default, the DNS modu 8.3 KB Diff Download File
Makefile 37 9 years ago francois at mozilla Fix new pep8 and pylint warnings 460 bytes Diff Download File
MANIFEST.in 3 12 years ago Francois Marier Add a changelog and make sure it's in the tarballs 22 bytes Diff Download File
README.txt 36 10 years ago Francois Marier Bump changelog and version number for release 1.9 KB Diff Download File
setup.py 36 10 years ago Francois Marier Bump changelog and version number for release 1.2 KB Diff Download File