The search for speed in Figma

Scott Laird10 Oct 2024

Problem

Figma's search team ran OpenSearch (a fork of ElasticSearch) on AWS's managed service. As the product grew, search got slow and unstable. The search API had a 99th percentile latency of almost one second, and at peak hours it was hundreds of milliseconds slower than on weekends. Datadog's OpenSearch integration showed an average search of about 8 ms, so the dashboards looked healthy while users waited.

Example from the article: OpenSearch reported about 8 ms on average, while the app's calls to the OpenSearch API library averaged 150 ms. The author says one figure was 120x the other.

Solution in brief

The team first fixed the measurement: it logged the took field of each query response, the only overall query time OpenSearch reports, and traced its own code. Most time went to query building and permission checks, not the engine. After fixing those, load tests on throwaway clusters showed that fewer shards, a much smaller index and more RAM per node cut latency and cost.

Questions this case answers
  • How to locate hidden latency in a search service when the engine's own timing metrics contradict the end-to-end latency users see
  • How to choose shard count, node type and index size for a latency-sensitive retrieval cluster whose vendor sizing guidance targets throughput-heavy workloads
  • How to find where the time goes when a search service is slow but the search engine reports fast queries?
  • How to size shards, nodes and index contents of an OpenSearch cluster for latency-sensitive document search?

Tools and methods

  • OpenSearch — the engine being tuned, on AWS's managed service.
  • took response field — overall query time, parsed from each response into monitoring.
  • Datadog — dashboards and traces.
  • OpenSearch query profiler — shows how many documents a query touches and where time goes.
  • Custom Go load-test tool — replays randomized queries against test clusters.
Continue reading — it's free

Google or a one-time email code. No password.