ElasticSearch(ES) performance Test

本文通过配置不同数量的分片,对比了Elasticsearch在大规模数据索引及搜索时的表现。使用JMeter进行压力测试,结果显示当分片过多时搜索性能明显下降。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

                ElasticSearch(ES) servers:  X.X.X.71, X.X.X.72, X.X.X.73.     72 and 73 with Mem:16G CPU:16 core 2.4GHz; 71 with Mem:8G CPU:4 core 2.27GHz       

 

                OS: Linux  x86_64 GNU/Linux

 

                tools: jmeter2.6 , youykit11.0.5

  • config & start service

 

         

 

              1. follow the offical installation guide of ES:ES Installation guide

 

                go to $ES_HOME and  start the ES with command( default config) :

./bin/elasticsearch 

 

  • preper jmeter script & index data

 

            1.  the index request for preper index-data to ES cluster look  like :

 

PUT http://X.X.X.71:9200/test/person/

PUT data:


[no cookies]

Request Headers:
Content-Length: 281
Connection: keep-alive

         the  format of  put data  (document for indexing) look like:

{oid:"456",ts:"1342463467567",name:"aluha",age:"10",company:"Cisco Systems, Inc.",branch:"Cloud Application Services",mail:"person@cisco.com",interest:"Have intensive interest in Internet-surfing,singing, writing and reading.",address:"address,The Golden Gate Bridge,Wall Street."}

        each doc for indexing  have a size about 300 bytes

 

    the detail of this script can find here:

 

         2. after got 15G index data with more than 20 million docs, we are ready to test the performance ofES, just keep the  same order of magnitude of index-data  as SolrCloud
 

  •  Test & Result

 

{note}

all test with NRT availible


{note}

    one or more clients to request to X.X.X.71-73 randomly. we have tow test cases

 

    (1)5 shards ,each with 2 replicas    (2) 1 shard, each with 2 replicas

 

  case (1)  :5 shards

 

       1. index performance test (with search): 

 

     index  result: index jmeter script elasticsearch_index_cluster.jmx

request thread numsavg response timethroughput
50192533
1501051446
3002001479

 at the same time the search result: search jmeter script  elasticsearch_search_cluster.jmx

request thread numsavg response timethroughput
5066274
1501200117
3001869154


 

       case(2) :1 shard

 

    1. index performance test (with search): 

 

     index  result: index jmeter script elasticsearch_index_cluster.jmx

request thread numsavg response timethroughput
50232314
1501582541
3001012946

 at the same time the search result: search jmeter script  elasticsearch_search_cluster.jmx

request thread numsavg response timethroughput
50153206
1501453230
300933167

       

  •  Summary

 

      the performance of indexing  between case 1 and case 2 is almost the same, but the performance of  searching while indexing is very bad when the shard is too many. with single searching  or indexing ,theES is very powerful. ES is also very good for small seach application. But for large scale data indexing and searching, too many shards will lead some problems.  It would be too hard for a new developer work withES due to its inactivity community and poor document compare withSolr. But ES has a lot of good feature we should bring into our system. Our team will step forword with this test. We will hava a  deeper research onES.

### 对 Elasticsearch 进行性能测试的工具和方法 #### 1. 使用官方推荐的压力测试工具 Esrally Es Rally 是由 Elastic 官方开发的一款专门针对 Elasticsearch 的基准测试工具。它可以帮助用户模拟真实场景下的负载情况,从而评估集群的性能表现。该工具支持多种工作负载定义方式,并提供详尽的结果报告以便进一步分析[^2]。 - **安装与配置**: 用户可以通过 pip 脚本简单完成安装过程 `pip install esrally` 。之后需要设置目标主机地址参数 target-hosts ,例如 `"--target-hosts=192.168.0.1:9200"` 来指向待测 Elasticsearch 实例[^4]。 - **执行测试命令**: ```bash esrally race --track=<TRACK_NAME> --challenge=<CHALLENGE_NAME> ``` #### 2. 利用 JMeter 执行自定义脚本化压测方案 Apache JMeter 不仅适用于 Web 应用程序的功能性和负载测试,同样也适合作为通用型 HTTP 请求生成器来评测基于 RESTful API 架构的服务质量水平,比如 Elasticsearch 查询操作效率等方面的表现状况[^1]。 - 创建线程组并添加 sampler 类型元件(HTTP Request),填写具体的 URL 地址以及请求体内容; - 设置断言条件验证返回值准确性; - 添加监听器组件记录统计数据图表展示形式呈现出来便于直观理解各项指标含义。 #### 3. 借助 Apache Benchmark (AB) 测试基础 GET/POST 接口速度 对于只需要初步了解某个单一查询语句耗时长短的情况来说,采用轻量化解决方案 AB 就显得尤为合适了。它可以迅速给出每秒处理请求数量(TPS),平均响应延迟等核心数据点作为参考依据之一[^3]。 - 示例命令如下所示: ```bash ab -n 1000 -c 10 'http://localhost:9200/_search?q=*:*' ``` 以上三种途径各有侧重方向不同,请根据实际需求选取最贴合业务特点的方式开展相应的工作流程规划实施起来更加高效合理些哦! ```python import requests def test_elasticsearch_performance(url, payload): response = requests.post(url=url, json=payload) return response.json() if __name__ == "__main__": url = "http://localhost:9200/_bulk" with open('data.json', 'r') as file: bulk_data = file.read() result = test_elasticsearch_performance(url, {"body": bulk_data}) print(result) ```
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值