Although the DNS RFC [14] allows the use of TCP in addition to UDP, in practice, TCP is used only when handling AXFR queries for the zone transfer or when the requested record set is bigger than 512 bytes. The reason why TCP is not favored in name lookups is mainly because of the additional overhead. If a TCP connection is needed for every query, it would end up handling nine packets instead of two : three to establish the connection, two for the request/response, and four to tear down the connection. A persistent TCP connection might remove the per-query connection overhead, but it also needs to consume one or two extra network packets for ACKs. Also, there is another issue of reclaiming the idle connections, since they consume system resources and can degrade performance. The DNS RFC [14] specifies two minutes as a cutoff but in practice most servers disconnect the idle connection within 30 seconds.
To compare the performance between UDP and TCP, we replay 10,792 unique hostnames obtained from one day's live traffic of a CoDeeN proxy at 107 PlanetLab nodes. Carrying out a completely fair comparison is difficult, since we cannot issue the same query for all of them at the same time. Instead, to give a relatively fair comparison, we run the test for CoDNS first, and subsequently run other parts, making all but CoDNS get the benefit of cached responses from the local nameserver after having been fetched by CoDNS. Figure 21 shows the CDF of the average response time for all approaches. Persistent TCP and UDP have comparable performance, while simple TCP is noticeably worse. The CoDNS latencies, included for reference, are better than all three.
The replay scenario described above should be favorable to TCP, but even in this conservative configuration, CoDNS still wins. Figure 22(a) shows that all nodes report that CoDNS is 10% to 500% faster than TCP, confirming CoDNS is a more attractive option than TCP. The large difference is in the slow-response portion, where CoDNS wins the most and where TCP-based lookups cannot help. Figure 22(b) shows that a considerable amount of time is still spent on the long delayed queries in TCP-based lookups. CoDNS reduces this time by 16% to 92% when compared to the TCP-based measurement. Though TCP ensures that the client's request reaches the nameserver, if the nameserver is overloaded, it may have trouble contacting the DNS hierarchy for cache misses.