Brifing

0 ms* Autocomplete for 240 Million Domain Names

How Wirewiki achieved an engineering marvel to elevate user experience to the highest level.

Hacker News2 min

1Wirewiki's Mission

Wirewiki provides a tool to inspect internet infrastructure. Users can check historical DNS records, DNS delegation, and email deliverability settings. With such services proliferating, Wirewiki aims to stand out through tool quality and user experience. Autocomplete is the primary navigation method, so it must be as fast and accurate as possible.

2The 0 ms* Target

Wirewiki aims for autocomplete to work the moment a user presses a key. As a key is pressed, suggestions for that key and possible next keys are prefetched. Upon key release, these suggestions are rendered instantly. On 60 Hz displays, this happens within a 16.7 ms frame. p99 0 ms means 99% of users see results before even releasing the key.

3Time Budget

The user's key press duration and gaps between presses determine the total time budget. Measurements from typing 100 domain names show a p99 time of 121 ms. This means the API must respond within this window. Wirewiki achieves this target, ensuring users perceive near-zero latency.

4Data Structures

Wirewiki uses two main data structures for autocomplete: the Tranco list (top 1 million domains) and the CZDS list (all domains for most gTLDs). The Tranco list is stored in a character trie (prefix tree), enabling prefix lookups via pointer traversal. The CZDS list is kept in sorted, delta-compressed blocks on SSD.

5Performance Optimization

The API first searches the Tranco list and, if necessary, the CZDS list. Results are returned in popularity order. The trie structure offers O(1) worst-case time complexity. CZDS searches use binary search and linear scanning. The 240 million domain names occupy about 2.5 GB of disk space, with hot pages cached by the OS.

6Network Latency

Each keystroke travels from the browser through Cloudflare to the Wirewiki server, adding network latency. In isolated tests, the API responds within 2 ms. With Nginx, this rises to 15 ms. Requests via Cloudflare introduce additional latency but absorb frequent traffic. A single server in Europe causes 100-200 ms delays for US traffic.

7Scalability

Wirewiki cannot achieve p99 0 ms with a single server. Geo load balancing and multiple servers could make this possible, but it may be overkill for a niche product. CDN caching and Nielsen's 0.1s 'instantaneous' threshold significantly improve UX. Wirewiki considers turning these optimizations into a product.

8Conclusion and Impact

Wirewiki's autocomplete solution exemplifies top-tier engineering for unparalleled UX. Trie and SSD optimizations deliver near-instant results for 240 million domains. Such optimizations can inspire other real-time applications. Wirewiki remains open to user feedback and continuous improvements.

Original article: Hacker News — 240 Milyon Alan Adı için 0 ms* Otomatik Tamamlama