SysPadLessons › database lessons › Algolia

How Algolia works

Hosted instant search (the typeahead-interview classic). Sub-30ms queries, priced per 1k searches - and typeahead fires a billable search on every keystroke unless you debounce.

"Design search-as-you-type" is a canonical interview question, and Algolia is the buy-side answer: sub-30ms results with typo tolerance out of the box. The economics have one twist worth internalizing: with instant search, every keystroke is potentially a billable query.

What you will learn

Why not just SQL LIKE?

Real search needs typo tolerance ("iphnoe" → iPhone), prefix matching at keystroke speed, relevance ranking, facets, and synonyms. Databases index for exact lookups; search engines build inverted indexes for fuzzy human intent. Algolia sells that engine pre-tuned, replicated near users, answering in ~20-30ms.

Keystrokes are the load

Instant search fires a query as the user types. One search intent ("macbook") becomes 3-8 billable requests depending on typing speed and your debounce. At ~$0.50 per 1,000 requests, UX generosity turns directly into invoice lines.

The build-vs-buy line

Algolia's price buys you zero ops, relevance tooling, and speed-to-ship. Sustained high volume flips the math: self-hosted OpenSearch/Typesense/Meilisearch trades an ops burden for a flat infrastructure cost. Teams commonly start on Algolia and revisit at the point where the bill rivals an engineer's time.

On the SysPad node, "Searches per user action" is the debounce dial: 8 vs 3 at the same RPS nearly triples the cost line. That slider is a UX meeting, monetized.

How does the data get INTO Algolia and stay fresh?

You push records via the indexing API whenever your source of truth changes (an event/outbox pattern in practice). Records are also billed, and the classic incident is an over-eager sync re-indexing everything hourly. Index what users search, not the whole row, and sync on change, not on schedule.

Flashcards

The search bill doubled after a redesign. The only frontend change: the new search box queries on every keystroke with no debounce. Explain the mechanics and the fix.
Each keystroke is a billable request, so average-intent queries went from ~3 to ~7+. Restore a 150-250ms debounce and a 2-3 character minimum; consider caching top prefixes.
A teammate proposes replacing Algolia with `WHERE title ILIKE '%query%'` to save money. What breaks?
Typo tolerance, ranking, prefix speed (leading-wildcard LIKE cannot use the index), and latency at scale. The cheap version of Algolia is a self-hosted search engine, not the database.
Search bill spiked with flat query volume. What is the OTHER meter to check?
Records/indexing operations: a sync job re-pushing the full catalog on a schedule bills heavily without a single extra user search. Sync deltas on change instead.

Sources

Open the SysPad canvas · Official Algolia documentation

Other database lessons