跳到主要内容

性能调优

本节提供了一些有关如何获得最佳性能的提示。

基本性能清单

如何提高吞吐量

要提高吞吐量(QPS),请增加索引的副本数量。

示例

The following example increases the number of replicas for example-index to 4.

下面分别是Python、JavaScript和Curl代码

pinecone.configure_index("example-index", replicas=4)

await pinecone.configureIndex("example-index", { replicas: 4 });

curl -i -X PATCH https://controller.us-west1-gcp.pinecone.io/databases/example-index \
-H 'Api-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"replicas": 4
}'

有关更多详细信息,请参见configure_index API 参考

使用 gRPC 客户端以获得更高的 upsert 速度

Pinecone提供了标准客户端的gRPC版本(安装),可为多Pod索引提供更高的upsert速度。

连接到gRPC客户端的索引:

Python


index = pinecone.GRPCIndex("index-name")

使用gRPC客户端的upsert、query、fetch和delete语法与标准客户端相同。

我们建议您使用并行upsert以获得最佳性能。

Python


index = pinecone.GRPCIndex('example-index')
def chunker(seq, batch_size):
return (seq[pos:pos + batch_size] for pos in range(0, len(seq), batch_size))
async_results = [
index.upsert(vectors=chunk, async_req=True)
for chunk in chunker(data, batch_size=100)
]
# Wait for and retrieve responses (in case of error)
[async_result.result() for async_result in async_results]

我们建议您仅在多Pod索引中使用gRPC客户端。标准客户端和gRPC客户端在单Pod索引中的性能相似。

使用gRPC索引进行upsert时,可能会更快地获得写入限制。如果您经常看到这种情况,我们建议您在upsert时使用回退算法。

Pinecone是线程安全的,因此您可以并行启动多个读取请求和多个写入请求。启动多个请求可以帮助提高吞吐量。但是,不能并行执行读取和写入,因此大批量写入可能会影响查询延迟,反之亦然。

最近更新:4个月前