Search Autocomplete diagram template
Type-ahead suggestions served from an in-memory trie rebuilt from query logs.
About this design
Autocomplete has a brutal latency budget: suggestions must arrive before the next keystroke, so there is no room for a database query on the hot path. This design serves prefixes from a trie held in memory on a fleet of suggestion servers, fronted by a cache and a CDN for the most common prefixes. The data comes from the other direction: search queries are logged to a stream, an offline pipeline counts them over a time window, filters out spam and offensive terms, and builds a fresh trie snapshot that servers load atomically. Trending terms can be mixed in from a faster, smaller pipeline. Use the template to discuss personalised versus global suggestions, how many characters to wait before calling the server, debouncing on the client, and how to roll back a bad snapshot quickly.
Diagram as text
This is the source of the diagram, in the ArchBoard diagram DSL. Paste it into Tools, Diagram from text to rebuild or change it.
title "Search autocomplete"
direction LR
browser "Search box" -> cdn "Edge cache" -> service suggest "Suggestion service"
[suggest x3]
suggest -> cache redis "Trie cache"
search-box -[query log]-> topic kafka "Query log" -> worker agg "Aggregator" -> storage s3 "Trie snapshots"
trie-snapshots -> suggest