A Look at the Evolution of Benchling’s Search Architecture

Matt Fox9 Mar 2022

Problem

Benchling is a cloud platform for biotech R&D. Search powers filtered lookup, full-text queries, folder navigation and @-mentions. Users expect to find an object right after they create or edit it, and slow or stale results erode trust. The first two designs hit different limits. The first suffered from indexing lag, the second from slow queries on normalized tables.

Example from the article: in the first design a change to one row in Postgres expanded to many Elasticsearch documents, and new or edited items did not appear in search for minutes or sometimes hours.

Solution in brief

Benchling went from per-customer Elasticsearch clusters (2015–2019) to search inside Postgres (2019–2021) and back to Elasticsearch with a dedicated search team (2021+). The current design keeps an asynchronous indexing pipeline but tracks changes per column, avoids filters that amplify writes, and can index synchronously inside the request when a user needs read-your-writes consistency.

Questions this case answers
  • How to keep a derived search index consistent with a normalized source-of-truth database when one row change fans out to many denormalized documents and indexing lag reaches minutes or hours
  • How to decide between searching inside the transactional database and running a dedicated search engine when data volume per tenant grows by orders of magnitude and the content is not natural-language text
  • How to keep product search results consistent with the core database when data volume per customer grows by orders of magnitude?
  • How to choose between search inside the core Postgres database and a dedicated Elasticsearch cluster?

Tools and methods

  • Elasticsearch — dedicated search store with full-text analyzers, plugins and fast query APIs
  • PostgreSQL — core database; in design two also the search engine (SQL queries, ts_vector, GIN indexes)
  • Change data capture (CDC) via Postgres triggers — in-house tracking of changes on searchable tables
  • Celery workers — asynchronous graph search for affected objects and document mapping
Continue reading — it's free

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