如何在Elasticsearch集群上最大化CPU核心 [英] How to max out CPU cores on Elasticsearch cluster
问题描述
我必须设置多少个分片和副本才能使用群集中的每个cpu核心(我想要100%的负载,最快的查询结果)?
How many shards and replicas do I have to set to use every cpu core (I want 100% load, fastest query results) in my cluster?
我想要使用Elasticsearch进行聚合。我读到Elasticsearch使用了多个cpu内核,但是没有找到关于cpu内核的分片和副本的确切细节。
I want to use Elasticsearch for aggregations. I read that Elasticsearch uses multiple cpu cores, but found no exact details about cpu cores regarding sharding and replicas.
我的观察是,单个分片不会使用超过查询时间1个核心/线程(考虑一次仅查询一个)。使用副本时,1-shard索引的查询不会更快,因为Elasticsearch似乎没有使用其他节点来分配分片上的负载。
My observations are, that a single shard does not use more than 1 core/thread at query time (considerung there is only one query at a time). With replicas, the query of a 1-shard index are not faster, since Elasticsearch does not seem to use the other nodes to distribute the load on a shard.
我的问题(一次查询一次):
My questions (one query at a time):
- 一个分片不使用多个cpu内核吗?
- 必须始终完全扫描碎片,不能使用副本来在节点之间划分碎片内部负载吗?
- 获得最佳性能的公式是SUM(每个节点CPU_CORES)* PRIMARY_SHARDS?
推荐答案
在执行操作(索引,搜索,批量索引等)时,节点上的分片会使用一个执行线程,即一个CPU内核。
When doing an operation (indexing, searching, bulk indexing etc) a shard on a node uses one thread of execution, meaning one CPU core.
如果在给定时刻运行一个查询,则每个分片将使用一个CPU内核。例如,一个具有单个索引的6个主碎片和一个副本的三节点群集将总共具有12个碎片,每个节点上具有4个碎片。
If you have one query running at a given moment, that will use one CPU core per shard. For example, a three node cluster with a single index that has 6 primary shards and one replica, will have in total 12 shards, 4 shards on each node.
只是在集群上运行的一个查询,对于该索引,ES将查询索引的所有6个分片(无论它们是主副本还是副本副本),并且每个节点将使用0到4个CPU内核进行作业,因为ES用于选择分片副本执行搜索的循环算法可以选择一个节点上没有分片,或一个节点上最多选择4个分片。
If there is only one query running on the cluster, for that index, ES will query all the 6 shards of the index (no matter if they are primaries or replicas) and each node will use between 0 and 4 CPU cores for the job, because the round-robin algorithm used by ES to choose which copy of a shard performs the search can choose no shards on one node or maximum 4 shards on one node.
这篇关于如何在Elasticsearch集群上最大化CPU核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!