Multi-node setup
Replication settings
The replication factor of a collection cannot be updated by updating the collection's definition.
From v1.32 by using replica movement, the replication factor of a shard can be changed.
Configure replication settings, such as async replication and deletion resolution strategy.
If a snippet doesn't work or you have feedback, please open a GitHub issue.
from weaviate.classes.config import Configure, ReplicationDeletionStrategy
client.collections.create(
"Article",
replication_config=Configure.replication(
factor=3,
deletion_strategy=ReplicationDeletionStrategy.TIME_BASED_RESOLUTION,
async_config=Configure.Replication.async_config(
hashtree_height=16,
frequency=30,
),
),
)
import { configure } from '@weaviate/node';
await replicationClient.collections.create({
name: 'Article',
replication: configure.replication({
factor: 3,
deletionStrategy: 'TimeBasedResolution',
asyncConfig: {
hashtreeHeight: 16,
frequency: 30,
},
}),
})
articleClass := &models.Class{
Class: "Article",
Description: "Collection of articles",
// Async replication runs by default when the replication factor is greater than 1
ReplicationConfig: &models.ReplicationConfig{
Factor: 3,
DeletionStrategy: models.ReplicationConfigDeletionStrategyTimeBasedResolution,
},
}
_, err := client.Collections.Create(ctx, collections.Collection{
Name: "Article",
Replication: &collections.ReplicationConfig{
Factor: 3,
DeletionStrategy: collections.TimeBasedResolution,
AsyncReplication: &collections.AsyncReplicationConfig{
HashTreeHeight: 16,
ReplicationFrequency: 30 * time.Millisecond,
},
},
})
if err != nil {
// handle error
panic(err)
}
threeNodeClient.collections.create("Article",
col -> col.replication(Replication.of(rep -> rep.replicationFactor(3)
.deletionStrategy(DeletionStrategy.TIME_BASED_RESOLUTION)
.asyncReplication(AsyncReplicationConfig.of(async -> async
.propagationConcurrency(5)
.hashTreeHeight(16)
.frequencyMillis(30))))));
await client.Collections.Create(
new CollectionCreateParams
{
Name = "Article",
ReplicationConfig = new ReplicationConfig
{
Factor = 1,
AsyncEnabled = true,
DeletionStrategy = DeletionStrategy.TimeBasedResolution,
},
}
);
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{
"class": "Article",
"properties": [
{
"dataType": [
"string"
],
"description": "Title of the article",
"name": "title"
}
],
"replicationConfig": {
"factor": 3,
"deletionStrategy": "TimeBasedResolution",
"asyncConfig": {
"hashtreeHeight": 16,
"frequency": 30000
}
}
}' \
http://localhost:8080/v1/schema
Additional information
To use replication factors greater than one, use a multi-node deployment.
For details on the configuration parameters, see the following:
Update replication settings
Update async replication settings for an existing collection. The asyncConfig parameters are mutable and can be changed at any time.
If a snippet doesn't work or you have feedback, please open a GitHub issue.
from weaviate.classes.config import Reconfigure
collection = client.collections.get("Article")
collection.config.update(
replication_config=Reconfigure.replication(
async_config=Reconfigure.Replication.async_config(
frequency=60,
),
),
)
const articleReplication = replicationClient.collections.use('Article')
await articleReplication.config.update({
replication: reconfigure.replication({
asyncConfig: {
frequency: 60,
},
}),
})
var collection = threeNodeClient.collections.use("Article");
collection.config.update(col -> col.replication(Replication.of(
rep -> rep.asyncReplication(AsyncReplicationConfig.of(async -> async
.propagationConcurrency(10)
.frequencyMillis(60))))));
Changing the hash tree height invalidates the existing tree and triggers a full rebuild. The rebuild duration scales with the number of objects in the collection, but it runs in the background and does not block reads or writes.
Sharding settings
Configure sharding per collection.
If a snippet doesn't work or you have feedback, please open a GitHub issue.
from weaviate.classes.config import Configure
client.collections.create(
"Article",
sharding_config=Configure.sharding(
virtual_per_physical=128,
desired_count=1,
desired_virtual_count=128,
),
)
import { configure } from '@weaviate/node';
await client.collections.create({
name: 'Article',
sharding: configure.sharding({
virtualPerPhysical: 128,
desiredCount: 1,
desiredVirtualCount: 128,
})
})
articleClass := &models.Class{
Class: "Article",
Description: "Collection of articles",
ShardingConfig: sharding.Config{
VirtualPerPhysical: 128,
DesiredCount: 1,
DesiredVirtualCount: 128,
Key: sharding.DefaultKey,
Strategy: sharding.DefaultStrategy,
Function: sharding.DefaultFunction,
},
}
_, err := client.Collections.Create(ctx, collections.Collection{
Name: "Article",
Sharding: &collections.ShardingConfig{
VirtualPerPhysical: 128,
DesiredCount: 1,
DesiredVirtualCount: 128,
},
})
if err != nil {
// handle error
panic(err)
}
client.collections.create("Article",
col -> col.sharding(Sharding.of(s -> s.virtualPerPhysical(128)
.desiredCount(1)
.desiredVirtualCount(128))));
await client.Collections.Create(
new CollectionCreateParams
{
Name = "Article",
ShardingConfig = new ShardingConfig
{
VirtualPerPhysical = 128,
DesiredCount = 1,
DesiredVirtualCount = 128,
},
}
);
Additional information
For details on the configuration parameters, see the following:
Inspect shards (for a collection)
v1.40An index itself can be comprised of multiple shards.
If a snippet doesn't work or you have feedback, please open a GitHub issue.
articles = client.collections.use("Article")
article_shards = articles.config.get_shards()
print(article_shards)
let articles = client.collections.use('Article')
const shards = await articles.config.getShards()
console.log(JSON.stringify(shards, null, 2));
package main
import (
"context"
"fmt"
"github.com/weaviate/weaviate-go-client/v5/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client, err := weaviate.NewClient(cfg)
if err != nil {
panic(err)
}
shards, err := client.Schema().
ShardsGetter().
WithClassName("Article").
Do(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("%v", shards)
}
CollectionHandle<Map<String, Object>> articles =
client.collections.use("Article");
List<Shard> articleShards = articles.config.getShards();
System.out.println(articleShards);
// Coming soon
GET /v1/schema/{collection}/shards reports the status of each shard on every replica. Each entry has a per_node_status object that maps a node name to the shard's status on that node. A replica that cannot be reached, or that cannot serve reads, reports UNAVAILABLE.
"per_node_status": { "node-0": "READY", "node-1": "UNAVAILABLE" }
status and vectorQueueSize are deprecated. Use per_node_status.
Update shard status
You can manually update a shard to change its status, for example to READONLY to stop writes, or back to READY. Shards marked READONLY because of disk pressure return to READY automatically from v1.36.0 on. See disk pressure warnings and limits.
If a snippet doesn't work or you have feedback, please open a GitHub issue.
articles = client.collections.use("Article")
article_shards = articles.config.update_shards(
status="READY",
shard_names=shard_names, # The names (List[str]) of the shard to update (or a shard name)
)
print(article_shards)
let articles = client.collections.use("Article");
const shards = await articles.config.updateShards("READY", "shard-1234");
console.log(JSON.stringify(shards, null, 2));
shardStatus, err := client.Schema().ShardUpdater().
WithClassName(myCollectionName). // Set your collection name
WithShardName(shardName). // Set the shard name to update
WithStatus("READY").
Do(ctx)
if err != nil {
// handle error
panic(err)
}
fmt.Printf("%v", shardStatus)
CollectionHandle<Map<String, Object>> articles =
client.collections.use("Article");
List<Shard> articleShards =
articles.config.updateShards(ShardStatus.READONLY, shardName);
System.out.println(articleShards);
// Coming soon
Further resources
Questions and feedback
Have a question or feedback? Here's how to reach us.
