การรองรับหลายผู้เช่าใน Weaviate
เรียนรู้การแยกข้อมูลตามผู้เช่าในคอลเลกชัน Weaviate เดียว เพื่อสร้างแอปพลิเคชันที่รองรับลูกค้าหลายรายได้อย่างปลอดภัยและขยายขนาดได้
การรองรับหลายผู้เช่าใน Weaviate เป็นบทเรียน Vector Databases: Pinecone, Weaviate & pgvector ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Vector Databases: Pinecone, Weaviate & pgvector และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Vector Databases: Pinecone, Weaviate & pgvector มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Why Multi-Tenancy?
Multi-tenancy lets one Weaviate collection serve many isolated customers (tenants) while keeping their data physically and logically separated.
- One schema, many tenants
- Strong data isolation
- Efficient resource use vs. one collection per customer
Enabling Multi-Tenancy
You enable multi-tenancy at collection creation time by setting multiTenancyConfig.enabled = true. Once enabled, every object must belong to a tenant.
{
"class": "Article",
"multiTenancyConfig": { "enabled": true }
}Creating Tenants
Tenants are added to a collection explicitly. Each tenant has a unique name and an activity status.
- HOT: active, queryable
- COLD: offloaded, must be activated first
POST /v1/schema/Article/tenants
[
{ "name": "customer-a" },
{ "name": "customer-b" }
]Inserting Tenant Data
When inserting objects you must specify which tenant owns the object. Data for one tenant is never visible to another.
{
"class": "Article",
"tenant": "customer-a",
"properties": { "title": "Hello" }
}Querying Per Tenant
Every query must include the tenant parameter. Weaviate scopes the search to that tenant's shard only, improving both isolation and performance.
{
Get {
Article (tenant: "customer-a", limit: 5) {
title
}
}
}Tenant Isolation Guarantees
Each tenant gets its own shard. This means:
- No cross-tenant data leakage
- Independent indexing per tenant
- Per-tenant lifecycle management
Activity Status & Offloading
Inactive tenants can be set to COLD to free memory, or offloaded to cloud storage. Reactivate them on demand to query again.
PUT /v1/schema/Article/tenants
[
{ "name": "customer-b", "activityStatus": "COLD" }
]Listing & Deleting Tenants
You can list all tenants of a collection or delete a tenant entirely. Deleting a tenant removes all its data permanently.
GET /v1/schema/Article/tenants
DELETE /v1/schema/Article/tenants
["customer-b"]Scaling with Many Tenants
Weaviate supports thousands of tenants efficiently because inactive shards consume minimal resources. Use COLD status aggressively for rarely-used tenants.
Python Client Example
The Python client makes tenant operations explicit via a tenant-scoped handle.
import weaviate
client = weaviate.connect_to_local()
articles = client.collections.get('Article')
tenant_a = articles.with_tenant('customer-a')
tenant_a.data.insert({'title': 'Edge case'})
client.close()Best Practices
Guidelines for multi-tenant Weaviate:
- Use one tenant per customer, not per request
- Set unused tenants to COLD
- Always validate the tenant param server-side to prevent enumeration
Quick Check
Test your understanding of multi-tenancy.
Recap
You learned to enable multi-tenancy, create and manage tenants, insert and query tenant-scoped data, and use COLD status for scaling. Multi-tenancy is the key to building secure, multi-customer apps on a single Weaviate collection.
คำถามที่พบบ่อย
บทเรียน “การรองรับหลายผู้เช่าใน Weaviate” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การรองรับหลายผู้เช่าใน Weaviate” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Vector Databases: Pinecone, Weaviate & pgvector ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Vector Databases: Pinecone, Weaviate & pgvector มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การรองรับหลายผู้เช่าใน Weaviate”
เรียนรู้การแยกข้อมูลตามผู้เช่าในคอลเลกชัน Weaviate เดียว เพื่อสร้างแอปพลิเคชันที่รองรับลูกค้าหลายรายได้อย่างปลอดภัยและขยายขนาดได้ คุณปฏิบัติ Vector Databases: Pinecone, Weaviate & pgvector ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Vector Databases: Pinecone, Weaviate & pgvector หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Vector Databases: Pinecone, Weaviate & pgvector บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “การรองรับหลายผู้เช่าใน Weaviate” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Vector Databases: Pinecone, Weaviate & pgvector นี้ได้ไหม
ได้ บทเรียน Vector Databases: Pinecone, Weaviate & pgvector ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- การค้นหาเชิงความหมายและการค้นหาแบบผสม
- การใช้โมดูล Weaviate
- กลยุทธ์การสำรองและกู้คืนข้อมูล
- การรองรับหลายผู้เช่าใน Weaviate