Design Glean
Understanding the Problem
🔎 What is enterprise search? Enterprise search gives employees one search box over all of their company's tools: documents in Google Drive or SharePoint, wiki pages in Confluence or Notion, tickets in Jira, messages in Slack or Teams, email, CRM records, code. Glean is the best-known product of this kind. On top of search, it offers an assistant that answers questions from that content with citations. The defining rule: a user must only ever see results they are allowed to open in the original app.
It looks like web search on a smaller corpus, but it's harder in two ways. First, we don't own the data. We mirror it from dozens of SaaS apps through their APIs, each with its own data model, rate limits and change notifications. Second, every document has its own permissions, which change constantly and are defined differently in every app. A web search engine ranks public pages for anyone; we rank private content for one specific person.
For the general search machinery (inverted indexes, sharding, ranking basics), see Web Search. For the RAG pipeline behind the assistant, see RAG System. Here we focus on what's unique: connectors, permissions and ranking inside a company.
Functional Requirements
Core Requirements
- Admins should be able to connect the company's apps (Slack, Google Drive, Confluence, Jira, Salesforce, GitHub, email and more), and content should stay in sync as it's created, edited and deleted.
- Users should be able to search across all connected apps from one box and get ranked results with titles, snippets and links to the original.
- Users should only see results, snippets and answers from content they can access in the source app.
- Users should be able to ask a natural-language question and get an answer with citations, generated only from content they can access.
Below the line (out of scope)
- Typeahead and query suggestions (see Typeahead).
- Agents that take actions in connected apps (creating tickets, sending messages). See Agentic Systems.
- Data loss prevention, retention policies and compliance search (eDiscovery).
- The detailed API of each connector.
Non-Functional Requirements
Ask about customer size. We'll serve 2,000 companies with 10M employees in total. The largest customer has 100,000 employees, 100 connected apps and about 1 billion items (messages, files, pages, tickets, emails).
Core Requirements
- The system must never show a user content they can't access in the source app, including in snippets, titles and AI answers. Revoked access should take effect within a few minutes.
- Search results should return in under 500 ms at p95; AI answers should start streaming within 3 seconds.
- New and edited content should be searchable within 5 minutes.
- The system should handle about 2,000 searches per second at peak across all customers.
- Customers must be strictly isolated from each other, and the system must stay within every app's API rate limits.
Below the line (out of scope)
- On-premises deployments for customers who can't use cloud apps at all.
The math that matters is about mirroring, not querying:
- Queries are modest. 10M employees x 5 searches a day = 50M a day, about 600 per second on average and around 2,000 at peak. That's comfortably within a sharded search cluster.
- Content is large. The biggest customer's 1 billion items at an average of ~2 KB of text is 2 TB of text, plus metadata and permissions. Most of it is chat messages.
- The first sync is slow. We can only read as fast as each app's API allows. If rate limits let us pull, say, 2,000 items per second for that customer across all apps, the initial backfill of 1 billion items takes 500,000 seconds, almost 6 days. We need to backfill the most useful content first and make the product useful before the crawl finishes.
- Permissions churn. People join and leave teams, channels and projects every day. One change to a shared folder can change access to millions of files underneath it.
The ranking model gets the attention, but the system lives or dies on two unglamorous things: connectors that stay in sync without hitting rate limits, and permissions that are never wrong. A search engine that leaks one HR document to the wrong person will be ripped out, no matter how good its ranking is.