The Spectrum Dispatch News

technology

Developer achieves near-instant autocomplete for 240M domain names

A Wirewiki creator uses client-side prefetching and optimized data structures to deliver search results in under 121 milliseconds—fast enough to appear instantaneous.

Developer achieves near-instant autocomplete for 240M domain names

Ruurtjan, creator of Wirewiki, a domain inspection tool, set out to build an autocomplete feature that would feel instantaneous to users. According to his writeup, he’s achieved p99 0ms latency—meaning 99% of the time, autocomplete results are ready before users release a key.

Developer achieves near-instant autocomplete for 240M domain names

The approach hinges on anticipatory prefetching: when a user presses a key, the system immediately requests suggestions for both the typed character and potential next characters. By the time the user releases the key, results are ready. This works because the time window between keyDown and keyUp events provides a natural latency budget. Ruurtjan measured this at approximately 121 milliseconds at the p99 percentile during typical typing speeds.

The backend uses two complementary data structures. For the top 1 million most popular domains (from the Tranco list), an in-memory character trie stores precomputed suggestions for every prefix, offering O(length of query) lookup complexity. For the remaining domains—sourced from CZDS, which provides domain lists for most generic top-level domains—the system uses an SSD-backed, memory-mapped block index with delta compression. This tail index binary-searches a 27 MB in-memory directory before scanning 256-name blocks, though the worst-case complexity is effectively O(1) given bounded input sizes. The full 240 million domains require approximately 2.5 GB of disk space.

Stress testing showed the API alone responds within 2 milliseconds for most requests. Even at 1,600 requests per second, the full stack (API plus Nginx) stays within 15 milliseconds at p99. In practice, end-to-end latency is dominated by network round-trip time through Cloudflare, adding roughly 10 milliseconds on top of that.

A key limitation acknowledged by Ruurtjan is geographic distribution. His current setup runs a single server in Europe, meaning users in the USA experience 100–200 milliseconds additional latency, exceeding the 121-millisecond budget. Deploying multiple geo-distributed servers would solve this, but he considers it unnecessary for Wirewiki’s current scope. He notes the niche nature of the tool makes it difficult to justify the infrastructure investment, though he would pursue it if converting the API into a commercial product.

Key facts

  • Autocomplete uses client-side prefetching triggered on keyDown and renders on keyUp to stay within the keypress duration window
  • Top 1 million domains are stored in an in-memory character trie; remaining domains use an SSD-backed, memory-mapped block index
  • The system handles 240 million domain names in approximately 2.5 GB of disk space
  • API responds within 2 milliseconds for most requests; full stack responds in 15 milliseconds at p99 under 1,600 requests per second
  • Single-server architecture limits geographic performance; USA traffic adds 100–200 milliseconds latency, exceeding the 121-millisecond target

Sources

← All posts