Page MenuHomePhabricator

Consider enabling short-term DNS caching in Parsoid
Closed, ResolvedPublic


While investigating DNS caching in the context of T125069, I noticed that nodejs does not cache any DNS responses by default. For a service like Parsoid that can send a lot of sub-requests, this means a lot of repeat DNS requests in a short amount of time.

To test the performance impact of this, I activated dnscache in server.js, using a 20s TTL:


var dnscache = require('dnscache')({
    "enable" : true,
    "ttl" : 20,
    "cachesize" : 1000

I then started up Parsoid with a single worker (-n 1), and benchmarked it with ab -n 10 http://localhost:8000/


  • 17230ms median without caching (master)
  • 16646ms median with 20s DNS caching

A second run with multiple workers showed similar results.

While the effect isn't huge on Obama (Parsoid is very much CPU-bound), it is noticeable. Given the very limited effort, enabling dnscache with a short TTL of 10 or 20s seems like an easy win.