mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-08 12:58:11 -05:00
[PR #13899] [MERGED] perf: implement multi-tenancy for Qdrant vector store client #62182
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/13899
Author: @loitragg
Created: 5/15/2025
Status: ✅ Merged
Merged: 5/15/2025
Merged by: @tjbck
Base:
dev← Head:apply-multitenant-for-qdrant📝 Commits (3)
184d8dffeat: Implement Qdrant multi-tenancy support with collection management and tenant isolation485bd76fix: Update Qdrant multi-tenancy variable name for consistency in configuration418ac1arefac: Rename Qdrant multi-tenancy variable for improved clarity and consistency📊 Changes
3 files changed (+721 additions, -3 deletions)
View changed files
📝
backend/open_webui/config.py(+1 -0)➕
backend/open_webui/retrieval/vector/dbs/qdrant_multitenancy.py(+712 -0)📝
backend/open_webui/retrieval/vector/factory.py(+8 -3)📄 Description
Pull Request Checklist
Before submitting, make sure you've checked the following:
devbranch.refactor)Changelog Entry
Discussions
Description
Background: In the discussion above, we were using a separate Qdrant collection for each entity (memory, knowledge base, file), which led to thousands of collections. This approach is an anti-pattern according to Qdrant documentation and causes excessive RAM usage.
Solution: Qdrant recommends using multi-tenancy with payload-based partitioning for efficient resource usage when dealing with a large number of logical collections (https://qdrant.tech/documentation/guides/multiple-partitions/). This change migrates the Qdrant database to utilize its multi-tenancy feature. Collections are now consolidated by entity type (Memories, Files, Knowledge, Web Search, YouTube), and data within these collections is partitioned using a
tenant_idfield in payloads.Changed
QdrantClientclass to use Qdrant's multi-tenancy feature while maintaining the same interface to avoid breaking changes in the application.Memories Collection,Files Collection,Knowledge Collection,Web Search Collection, andHash Based Collection(for Youtube and Web URL).tenant_idfield for data isolation within the new collections.payload_m=16(per-tenant indexing),m=0(disabled global index), and a keyword payload index fortenant_idwithis_tenant=true.QDRANT_MULTI_TENANCYenvironment variable and do a reindex.Additional Information
Migration
The existing API interface of the
QdrantClientclass is maintained to avoid breaking changes in the application, ensuring a seamless transition. However, Open WebUI will unable to access all the old Qdrant collections. Go to: Admin Settings > Documents > Reindex Knowledge Base Vectors to migrating knowledgeRollback
Before running the migration in production:
If you need to roll back, restore from your backup.
Benefits of Multi-Tenancy
Before
After
Sequence Diagram(s)
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.