[英]OpenSearch compute knn index size properly
我在 AWS 中使用 OpenSearch 服务进行研究。
任务:我想计算索引中 N 条记录的索引大小。
输入:我在 AWS [r6g.4xlarge.search] 中只有一个节点,具有 128 个 RAM。 索引定义为:
{
"settings": {
"index": {
"knn": True,
"knn.space_type": "cosinesimil",
'number_of_replicas': 0,
'refresh_interval': -1,
'translog.flush_threshold_size': '10gb',
}
},
"mappings": {
"properties": {
"vector": {
"type": "knn_vector",
"dimension": 512
},
"keyword1": {
"type": "keyword"
},
"keyword2": {
"type": "keyword"
}
}
}
}
我看到强制合并+刷新后我有5个段。
KNN 统计数据如下所示:
{"_nodes": {"total": 1, "successful": 1, "failed": 0}, "cluster_name": "NAME",
"circuit_breaker_triggered": false, "nodes": {
"ID": {"miss_count": 7, "graph_memory_usage_percentage": 34.527355,
"graph_query_requests": 475, "graph_memory_usage": 16981999,
"cache_capacity_reached": false, "graph_index_requests": 5,
"load_exception_count": 0, "load_success_count": 7, "eviction_count": 0,
"indices_in_cache": {
"INDEX_NAME": {"graph_memory_usage_percentage": 34.527355,
"graph_memory_usage": 16981999,
"graph_count": 5}},
"script_query_errors": 0, "script_compilations": 0,
"script_query_requests": 0, "graph_query_errors": 0, "hit_count": 468,
"graph_index_errors": 0, "knn_query_requests": 95,
"total_load_time": 57689947272, "script_compilation_errors": 0}}}
我发现在我的情况下所需的 memory 数量是OpenSearch :1.1 *(4 * 维度 + 8 * M)字节。 其中维度 = 512,M = 16,每条记录给我 0.0000023936。 现在我在索引中有 7885767 个文档,它需要 16981999 = ±16GB - 32% 的使用量来自有效 memory。 所以它甚至比公式所说的还要少。
但是,如果我计算可用的 memory,它会给我大约 50GB,例如 128 GB RAM。 根据 AWS 文档(检查底线) ,OpenSearch 本身最多占用 32 GB,所以还剩下 96 个。 你能解释一下如何编写一个公式来正确估计索引中的文档数量吗?
答案很简单。 如果你只使用 knn 搜索(像我一样),你可以简单地增加这个参数来调整你机器的最大 RAM knn.memory.circuit_breaker.limit
设置
您可以从 python (或 elasticsearch api)更改它
import elasticsearch
es = elasticsearch.Elasticsearch(
hosts=["host"],
http_auth=(
"admin",
"admin",
),
timeout=3600,
)
res = es.cluster.put_settings(
{"persistent": {"knn.memory.circuit_breaker.limit": "100%"}}
)
print(res)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.