You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/gen-ai/quickstart-rag-chatbot.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,14 +14,14 @@ ms.author: thvankra
14
14
15
15
[!INCLUDE[NoSQL](../includes/appliesto-nosql.md)]
16
16
17
-
In this sample, we'll demonstrate how to build a RAG Pattern application using a subset of the Movie Lens dataset. This sample will leverage the Python SDK for Azure Cosmos DB for NoSQL to perform vector search for RAG, store and retrieve chat history, and store the vectors of the chat history to use as a semantic cache. Azure OpenAI to generate embeddings and LLM completions.
17
+
In this quickstart, we demonstrate how to build a RAG Pattern application using a subset of the Movie Lens dataset. This sample uses the Python SDK for Azure Cosmos DB for NoSQL to perform vector search for RAG, store and retrieve chat history, and store the vectors of the chat history to use as a semantic cache. Azure OpenAI is used to generate embeddings and Large Language Model (LLM) completions.
18
18
19
-
At the end, we will create a simple UX using Gradio to allow users to type in questions and display responses generated by a GPT model or served from the cache. The responses will also display an elapsed time so you can see the impact caching has on performance versus generating a response.
19
+
At the end, we create a simple UX using Gradio to allow users to type in questions and display responses generated by Azure OpenAI or served from the cache. The responses also display an elapsed time so you can see the impact caching has on performance versus generating a response.
20
20
21
21
> [!TIP]
22
22
> For more samples, visit: [AzureDataRetrievalAugmentedGenerationSamples](https://github.com/microsoft/AzureDataRetrievalAugmentedGenerationSamples)
23
23
24
-
**Important Note**: This sample requires you to have Azure Cosmos DB for NoSQL and Azure OpenAI accounts set up. To get started, visit:
24
+
**Important Note**: This sample requires you to setup accounts for Azure Cosmos DB for NoSQL, and Azure OpenAI. To get started, visit:
25
25
-[Azure Cosmos DB for NoSQL Python Quickstart](../nosql/quickstart-python.md)
26
26
-[Azure Cosmos DB for NoSQL Vector Search](../nosql/vector-search.md)
### 3. Create a Database and Containers with Vector Policies
83
-
This function takes a database object, a collection name, the name of the document property that will store vectors, and the number of vector dimensions used for the embeddings.
83
+
This function takes a database object, a collection name, the name of the document property that stores vectors, and the number of vector dimensions used for the embeddings.
84
84
85
85
```python
86
86
db =await cosmos_async_client.create_database_if_not_exists(cosmos_database)
@@ -170,7 +170,7 @@ len(data)
170
170
171
171
### 6. Store Data in Azure Cosmos DB
172
172
173
-
Upsert data into Azure Cosmos DB for NoSQL. Records will be written asynchronously.
173
+
Upsert data into Azure Cosmos DB for NoSQL. Records are written asynchronously.
Copy file name to clipboardExpand all lines: articles/cosmos-db/nosql/multi-tenancy-vector-search.md
+30-30Lines changed: 30 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: Multi-Tenancy in Azure Cosmos DB
3
-
description: Learn concepts for building multi-tenant gen-ai apps in Azure Cosmos DB
2
+
title: Multi-tenancy in Azure Cosmos DB
3
+
description: Learn concepts for building multitenant gen-ai apps in Azure Cosmos DB
4
4
author: TheovanKraay
5
5
ms.service: cosmos-db
6
6
ms.subservice: nosql
@@ -9,26 +9,26 @@ ms.date: 06/26/2024
9
9
ms.author: thvankra
10
10
---
11
11
12
-
# Multi-Tenancy in Azure Cosmos DB
12
+
# Multi-tenancy for vector search in Azure Cosmos DB
13
13
14
14
> "OpenAI relies on Cosmos DB to dynamically scale their ChatGPT service – one of the fastest-growing consumer apps ever – enabling high reliability and low maintenance."
15
-
> - Satya Nadella
15
+
> — Satya Nadella
16
16
17
-
Azure Cosmos DB stands out as the world's first serverless vector search database, offering unparalleled scalability and performance. By leveraging Azure Cosmos DB, users can enhance their vector search capabilities, ensuring high reliability and low maintenance for multi-tenant applications.
17
+
Azure Cosmos DB stands out as the world's first serverless vector search database, offering unparalleled scalability and performance. By using Azure Cosmos DB, users can enhance their vector search capabilities, ensuring high reliability and low maintenance for multitenant applications.
18
18
19
19
Multi-tenancy enables a single instance of a database to serve multiple customers, or tenants, simultaneously. This approach efficiently shares infrastructure and operational overhead, resulting in cost savings and simplified management. It's a crucial design consideration for SaaS applications and some internal enterprise solutions.
20
20
21
-
Multi-tenancy introduces complexity. Your system must scale efficiently to maintain high performance across all tenants, who may have unique workloads, requirements, and SLAs.
21
+
Multi-tenancy introduces complexity. Your system must scale efficiently to maintain high performance across all tenants, who may have unique workloads, requirements, and service-level agreements (SLAs).
22
22
23
23
Imagine a fictional AI-assisted research platform called ResearchHub. Serving thousands of companies and individual researchers, ResearchHub manages varying user bases, data scales, and SLAs. Ensuring low query latency and high performance is vital for sustaining an excellent user experience.
24
24
25
-
Azure Cosmos DB, with its [DiskANN vector index](../index-policy.md#vector-indexes) capability, simplifies multi-tenant design, providing efficient data storage and access mechanisms for high-performance applications.
25
+
Azure Cosmos DB, with its [DiskANN vector index](../index-policy.md#vector-indexes) capability, simplifies multitenant design, providing efficient data storage and access mechanisms for high-performance applications.
26
26
27
-
### Multi-Tenancy Models in Cosmos DB
27
+
### Multi-tenancy models in Azure Cosmos DB
28
28
29
29
In Azure Cosmos DB, we recommend two primary approaches to managing multi-tenancy: partition key-per-tenant or account-per-tenant, each with its own set of benefits and trade-offs.
30
30
31
-
#### 1. Partition Key-Per-Tenant
31
+
#### 1. Partition key-per-tenant
32
32
33
33
For a higher density of tenants and lower isolation, the partition key-per-tenant model is effective. Each tenant is assigned a unique partition key within a given container, allowing logical separation of data.
34
34
@@ -41,19 +41,19 @@ For a higher density of tenants and lower isolation, the partition key-per-tenan
41
41
-**Resource Contention:** Shared resources can lead to contention during peak usage.
42
42
-**Limited Isolation:** Logical but not physical isolation, which may not meet stringent security needs.
43
43
44
-
#### Hierarchical Partitioning: Enhanced Data Organization
44
+
#### Hierarchical partitioning: enhanced data organization
45
45
46
46
[Hierarchical partitioning](../hierarchical-partition-keys.md) builds on the partition key-per-tenant model, adding deeper levels of data organization. This method involves creating multiple levels of partition keys for more granular data management.
47
47
48
48
**Advantages:**
49
-
-**Optimized Queries:** More precise targeting of sub-partitions at the parent partition level reduces query latency.
49
+
-**Optimized Queries:** More precise targeting of subpartitions at the parent partition level reduces query latency.
50
50
-**Improved Scalability:** Facilitates deeper data segmentation for easier scaling.
ResearchHub can stratify data within each tenant’s partition by organizing it at departmental levels, facilitating efficient management and queries.
55
55
56
-
#### 2. Account-Per-Tenant
56
+
#### 2. Account-per-tenant
57
57
58
58
For maximum isolation, the account-per-tenant model is preferable. Each tenant gets a dedicated Cosmos DB account, ensuring complete separation of resources.
59
59
@@ -66,9 +66,9 @@ For maximum isolation, the account-per-tenant model is preferable. Each tenant g
66
66
-**Increased Management:** Higher complexity in managing multiple Cosmos DB accounts.
67
67
-**Higher Costs:** More accounts mean higher infrastructure costs.
68
68
69
-
### Security Isolation with Customer Managed Keys
69
+
### Security isolation with customer-managed keys
70
70
71
-
Azure Cosmos DB enables [customer-managed keys](../how-to-setup-customer-managed-keys.md) for data encryption, adding an extra layer of security for multi-tenant environments.
71
+
Azure Cosmos DB enables [customer-managed keys](../how-to-setup-customer-managed-keys.md) for data encryption, adding an extra layer of security for multitenant environments.
72
72
73
73
**Steps to Implement:**
74
74
1.**Set Up Azure Key Vault:** Securely store your encryption keys.
@@ -77,13 +77,13 @@ Azure Cosmos DB enables [customer-managed keys](../how-to-setup-customer-managed
77
77
78
78
Using customer-managed keys ensures each tenant's data is encrypted uniquely, providing robust security and compliance.
79
79
80
-
### Other Isolation Models
80
+
### Other isolation models
81
81
82
-
#### Container and Database Isolation
82
+
#### Container and database isolation
83
83
84
84
In addition to the partition key-per-tenant and account-per-tenant models, Azure Cosmos DB provides other isolation methods such as container isolation and database isolation. These approaches offer varying degrees of performance isolation, though they don't provide the same level of security isolation as the account-per-tenant model.
85
85
86
-
##### Container Isolation
86
+
##### Container isolation
87
87
88
88
In the container isolation model, each tenant is assigned a separate container within a shared Cosmos DB account. This model allows for some level of isolation in terms of performance and resource allocation.
89
89
@@ -93,10 +93,10 @@ In the container isolation model, each tenant is assigned a separate container w
93
93
-**Cost Efficiency:** Similar to the partition key-per-tenant model, this method reduces the overhead of multiple accounts.
94
94
95
95
**Drawbacks:**
96
-
-**Limited Security Isolation:** Unlike separate accounts, containers within the same account do not provide physical data isolation. Consequently, this model may not meet stringent security requirements.
96
+
-**Limited Security Isolation:** Unlike separate accounts, containers within the same account don't provide physical data isolation. So, this model may not meet stringent security requirements.
97
97
-**Resource Contention:** Heavy workloads in one container can still affect others if resource limits are breached.
98
98
99
-
##### Database Isolation
99
+
##### Database isolation
100
100
101
101
The database isolation model assigns each tenant a separate database within a shared Cosmos DB account. This provides enhanced isolation in terms of resource allocation and management.
102
102
@@ -109,20 +109,20 @@ The database isolation model assigns each tenant a separate database within a sh
109
109
-**Limited Security Isolation:** Similar to container isolation, having separate databases within a single account does not provide physical data isolation.
110
110
-**Complexity:** Managing multiple databases can be more complex than managing containers, especially as the number of tenants grows.
111
111
112
-
While container and database isolation models do not offer the same level of security isolation as the account-per-tenant model, they can still be useful for achieving performance isolation and flexible resource management. These methods are particularly beneficial for scenarios where cost efficiency and simplified management are priorities, and stringent security isolation is not a critical requirement.
112
+
While container and database isolation models don't offer the same level of security isolation as the account-per-tenant model, they can still be useful for achieving performance isolation and flexible resource management. These methods are beneficial for scenarios where cost efficiency and simplified management are priorities, and stringent security isolation is not a critical requirement.
113
113
114
-
By carefully evaluating the specific needs and constraints of your multi-tenant application, you can choose the most suitable isolation model in Azure Cosmos DB, balancing performance, security, and cost considerations to achieve the best results for your tenants.
114
+
By carefully evaluating the specific needs and constraints of your multitenant application, you can choose the most suitable isolation model in Azure Cosmos DB, balancing performance, security, and cost considerations to achieve the best results for your tenants.
115
115
116
-
### Real-World Implementation Considerations
116
+
### Real-world implementation considerations
117
117
118
-
When designing a multi-tenant system with Cosmos DB, consider these factors:
118
+
When designing a multitenant system with Cosmos DB, consider these factors:
119
119
120
120
-**Tenant Workload:** Evaluate data size and activity to select the appropriate isolation model.
121
121
-**Performance Requirements:** Align your architecture with defined SLAs and performance metrics.
122
122
-**Cost Management:** Balance infrastructure costs against the need for isolation and performance.
123
123
-**Scalability:** Plan for growth by choosing scalable models.
124
124
125
-
### Practical Implementation in Cosmos DB
125
+
### Practical implementation in Azure Cosmos DB
126
126
127
127
**Partition Key-Per-Tenant:**
128
128
1.**Assign Partition Keys:** Unique keys for each tenant ensure logical separation.
@@ -139,12 +139,12 @@ When designing a multi-tenant system with Cosmos DB, consider these factors:
139
139
2.**Customize Resources:** Tailor performance and SLAs to tenant requirements.
140
140
3.**Ensure Security:** Physical data isolation offers robust security and compliance.
141
141
142
-
### Best Practices for Using Azure Cosmos DB with Vector Search Capabilities
142
+
### Best practices for using Azure Cosmos DB with vector search
143
143
144
144
Azure Cosmos DB's support for DiskANN vector index capability makes it an excellent choice for applications that require fast, high-dimensional searches, such as AI-assisted research platforms like ResearchHub. Here’s how you can leverage these capabilities:
145
145
146
146
**1. Efficient Storage and Retrieval:**
147
-
-**Vector Indexing:** Use the DiskANN vector index to efficiently store and retrieve high-dimensional vectors. This is particularly useful for applications that involve similarity searches in large datasets, such as image recognition or document similarity.
147
+
-**Vector Indexing:** Use the DiskANN vector index to efficiently store and retrieve high-dimensional vectors. This is useful for applications that involve similarity searches in large datasets, such as image recognition or document similarity.
148
148
-**Performance Optimization:** DiskANN’s vector search capabilities enable quick, accurate searches, ensuring low latency and high performance, which is critical for maintaining a good user experience.
149
149
150
150
**2. Scaling Across Tenants:**
@@ -155,7 +155,7 @@ Azure Cosmos DB's support for DiskANN vector index capability makes it an excell
155
155
-**Customer Managed Keys:** Implement customer-managed keys for data encryption at rest, ensuring each tenant’s data is securely isolated.
156
156
-**Regular Key Rotation:** Enhance security by regularly rotating encryption keys stored in Azure Key Vault.
157
157
158
-
### Real-World Example: Implementing ResearchHub
158
+
### Real-world example: implementing ResearchHub
159
159
160
160
**Partition Key-Per-Tenant:**
161
161
1.**Assign Partition Keys:** Each organization (tenant) is assigned a unique partition key.
@@ -164,7 +164,7 @@ Azure Cosmos DB's support for DiskANN vector index capability makes it an excell
164
164
165
165
**Hierarchical Partitioning:**
166
166
1.**Multi-Level Partition Keys:** Data within a tenant’s partition is further segmented by department, project, or other relevant attributes.
167
-
2.**Granular Data Management:** This hierarchical approach allows ResearchHub to manage and query data more efficiently, reducing latency and improving response times.
167
+
2.**Granular Data Management:** This hierarchical approach allows ResearchHub to manage and query data more efficiently, reducing latency, and improving response times.
168
168
169
169
**Account-Per-Tenant:**
170
170
1.**Separate Cosmos DB Accounts:** High-profile clients or those with sensitive data are provided individual Cosmos DB accounts.
@@ -173,9 +173,9 @@ Azure Cosmos DB's support for DiskANN vector index capability makes it an excell
173
173
174
174
### Conclusion
175
175
176
-
Multi-tenancy in Azure Cosmos DB, especially with its DiskANN vector index capability, offers a powerful solution for building scalable, high-performance AI applications. Whether you choose partition key-per-tenant, hierarchical partitioning, or account-per-tenant models, you can effectively balance cost, security, and performance. By leveraging these models and best practices, you can ensure that your multi-tenant application meets the diverse needs of your customers, delivering an exceptional user experience.
176
+
Multi-tenancy in Azure Cosmos DB, especially with its DiskANN vector index capability, offers a powerful solution for building scalable, high-performance AI applications. Whether you choose partition key-per-tenant, hierarchical partitioning, or account-per-tenant models, you can effectively balance cost, security, and performance. By using these models and best practices, you can ensure that your multitenant application meets the diverse needs of your customers, delivering an exceptional user experience.
177
177
178
-
Azure Cosmos DB provides the tools necessary to build a robust, secure, and scalable multi-tenant environment. With the power of DiskANN vector indexing, you can deliver fast, high-dimensional searches that drive your AI applications.
178
+
Azure Cosmos DB provides the tools necessary to build a robust, secure, and scalable multitenant environment. With the power of DiskANN vector indexing, you can deliver fast, high-dimensional searches that drive your AI applications.
0 commit comments