Overview
In Weaviate, multi-tenancy allows a collection to efficiently serve isolated groups of data. Each "tenant" in a multi-tenant collection can only access its own data, while sharing the same data structure and settings.
This allows Weaviate to efficiently serve a large number of tenants with minimal overhead. And as you will see later, you can manage individual tenants to balance performance and resource usage.
"Multi-tenancy" in other contexts
In general, the term "multi-tenancy" refers to a software architecture where a single instance of the software serves multiple "tenants". In that context, each tenant may be a group of users who share common access.
This is similar to the concept of multi-tenancy in Weaviate, where each tenant is a group of data that is isolated from other tenants.
Why use multi-tenancy?
A typical multi-tenancy use-case is in a software-as-a-service (SaaS) application. In many SaaS applications, each end user or account will have private data that should be not be accessible to anyone else.
Example case study
In this course, we'll learn about multi-tenancy by putting ourselves in the shoes of a developer building an application called MyPrivateJournal
.
MyPrivateJournal
is a SaaS (software-as-a-service) application where users like Steve, Alice and so on can write and store their journal entries. Each user's entries should be private and not accessible to anyone else.
Using single-tenant collections, you might implement this with:
- A monolithic collection: To store the entire dataset, with an end user identifier property
- Per end-user collections: Where each end user's data would be in a separate collection
While these may work to some extent, both of these options have significant limitations.
- Using a monolithic collection:
- A developer mistake could easily expose Steve's entries to Alice, which would be a significant privacy breach.
- As
MyPrivateJournal
grows, Steve's query would become slower as it must look through the entire collection. - When Steve asks
MyPrivateJournal
to delete his data, the process would be complex and error-prone.
- Using end-user-specific collections:
MyPrivteJournal
may need to spend more on hardware to support the high number of collections.- Changes to configurations (e.g. adding a new property) would need to be run separately for each collection.
Multi-tenancy in Weaviate solves these problems by providing a way to isolate each user's data while sharing the same configuration.
Benefits of multi-tenancy
In multi-tenant collection, each "tenant" is isolated from each other, while sharing the same set of configurations. This arrangement helps make multi-tenancy far more resource-efficient than using many individual collections.
A Weaviate node can host more tenants than single-tenant collections.
It also makes developers' job easier, as there is only one set of collection configurations. The data isolation between tenants eliminates risks of accidental data leakage and makes it easier to manage individual tenants and tenant data.
MyPrivateJournal
and multi-tenancy
So, the MyPrivateJournal
app can use multi-tenancy and store each user's journal entries in a separate tenant. This way, Steve's entries are isolated from Alice's, and vice versa. This isolation makes it easier to manage each user's data and reduces the risk of data leakage.
As you will see later, MyPrivateJournal
can also offload inactive users' data to cold storage, reducing the hot (memory) and warm (disk) resource usage of the Weaviate node.
Tenants vs collections
Each multi-tenant collection can have any number of tenants.
A tenant is very similar to a single-tenant collection. For example:
Aspect | Tenant | Single-tenant collection |
---|---|---|
Objects | Belong to a tenant | Belong to a collection |
Vector indexes | Belong to a tenant | Belong to a collection |
Inverted indexes | Belong to a tenant | Belong to a collection |
Deletion | Deleting a tenant deletes all tenant data | Deleting a collection deletes all collection data |
Query | Can search one tenant at a time | Can search one collection at a time |
But as you will have guessed, there are also differences. We'll cover these in the next sections, as we follow MyPrivateJournal
implementing multi-tenancy in Weaviate.
Questions and feedback
If you have any questions or feedback, let us know in the user forum.