Design a scalable tagging system
Design a Scalable Multi-Tenant Tagging Service
You are tasked with designing a highly scalable, multi-tenant tagging service for a large-scale SaaS product. This service will allow items (such as documents, issues, or pages) to be associated with multiple tags. The system must support high read and write throughput, as well as efficient querying by single or multiple tags.
Scale Assumptions
Consider the following scale characteristics:
- Items: 100 million items
- Distinct Tags: 10 million distinct tags
- Tags per Item: An average of 5-20 tags per item
- Peak Read QPS: 10,000 queries per second
- Peak Write QPS: 2,000 tag add/remove operations per second
- Multi-tenancy: Strict isolation between tenants is required.
Core Requirements
- Tag Management: Support the creation, retrieval, update, and deletion of tags.
- Item-Tag Association: Enable associating and dissociating multiple tags with an item.
- Querying: Provide robust querying capabilities for items:
- By a single tag.
- By a combination of tags (using
ANDandORlogic). - Support pagination and sorting (e.g., by recency) for query results.
- Performance: Achieve high availability and low latency for read operations, alongside scalable write performance.
- Consistency: Clearly define and implement a suitable consistency model (e.g., eventual consistency vs. read-your-writes) for tag operations.
- Scalability Mechanisms: Detail strategies for sharding, caching, and indexing to handle the specified scale.
- Operability: Include considerations for monitoring, reindexing, and backfill processes.
Deliverables
Your design should cover the following aspects:
- Data Model and Storage: Propose a data model and justify your choice of storage technologies.
- API Design: Outline the read and write paths, including relevant API endpoints.
- Indexing Strategy: Describe your approach to indexing for both single and combined tag queries.
- Sharding/Partitioning: Present a plan for distributing data across multiple nodes.
- Caching Strategy: Detail your caching mechanisms and invalidation policies.
- Consistency Trade-offs: Discuss the trade-offs involved in your chosen consistency model and how it's implemented.
- Edge Cases: Explain how you would handle challenges like hot tags, data skew, and system growth.
AI interview prep
Core dilemma
The central engineering conflict is balancing the need for highly efficient, complex boolean queries (AND/OR) across a massive dataset (100M items, 10M tags) with high write throughput (2k QPS for tag associations/dissociations), all while maintaining multi-tenant isolation and specific consistency guarantees.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design a scalable tagging system
Design a Scalable Multi-Tenant Tagging Service
You are tasked with designing a highly scalable, multi-tenant tagging service for a large-scale SaaS product. This service will allow items (such as documents, issues, or pages) to be associated with multiple tags. The system must support high read and write throughput, as well as efficient querying by single or multiple tags.
Scale Assumptions
Consider the following scale characteristics:
- Items: 100 million items
- Distinct Tags: 10 million distinct tags
- Tags per Item: An average of 5-20 tags per item
- Peak Read QPS: 10,000 queries per second
- Peak Write QPS: 2,000 tag add/remove operations per second
- Multi-tenancy: Strict isolation between tenants is required.
Core Requirements
- Tag Management: Support the creation, retrieval, update, and deletion of tags.
- Item-Tag Association: Enable associating and dissociating multiple tags with an item.
- Querying: Provide robust querying capabilities for items:
- By a single tag.
- By a combination of tags (using
ANDandORlogic). - Support pagination and sorting (e.g., by recency) for query results.
- Performance: Achieve high availability and low latency for read operations, alongside scalable write performance.
- Consistency: Clearly define and implement a suitable consistency model (e.g., eventual consistency vs. read-your-writes) for tag operations.
- Scalability Mechanisms: Detail strategies for sharding, caching, and indexing to handle the specified scale.
- Operability: Include considerations for monitoring, reindexing, and backfill processes.
Deliverables
Your design should cover the following aspects:
- Data Model and Storage: Propose a data model and justify your choice of storage technologies.
- API Design: Outline the read and write paths, including relevant API endpoints.
- Indexing Strategy: Describe your approach to indexing for both single and combined tag queries.
- Sharding/Partitioning: Present a plan for distributing data across multiple nodes.
- Caching Strategy: Detail your caching mechanisms and invalidation policies.
- Consistency Trade-offs: Discuss the trade-offs involved in your chosen consistency model and how it's implemented.
- Edge Cases: Explain how you would handle challenges like hot tags, data skew, and system growth.