elasticsearch性能测试工具rally深入详解

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
性能测试 PTS,5000VUM额度
简介: elasticsearch性能测试工具rally深入详解 题记 elasticsearch性能测试研究了很久,自己想过通过批量导入数据,然后记录时间,统计CPU、内存等变化,计算得出某个性能指标。但显然,数据量起伏不定,非常不准确。

elasticsearch性能测试工具rally深入详解

题记
elasticsearch性能测试研究了很久,自己想过通过批量导入数据,然后记录时间,统计CPU、内存等变化,计算得出某个性能指标。但显然,数据量起伏不定,非常不准确。 
研究发现,github上提供了rally作为elasticsearch的性能测试工具,较好的解决了es性能测试问题。

1、esrally功能:es的性能测试工具。
esrally不支持windows版本,目前只支持Linux和Mac OS。 
esrally的运行基于以下两点假设: 
1)所有运行在同一台机器完成。(未来改假设条件可能会去掉) 
2)你需要向Elasticsearch索引中添加特定的数据集,然后在其上进行基准查询(benchmarking queries).

2、esrally安装:
前提:验证是否安装了以下内容(注意版本) 
Python 3.4+ available as python3 on the path (verify with: python3 –version which should print Python 3.4.0 or higher) 
pip3 available on the path (verify with pip3 –version) 
JDK 8 
git

如下所示:

[root@laoyang git-2.4.0]# python
Python 3.5.1 (default, Aug 2 2016, 09:53:20)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.

[root@laoyang git-2.4.0]# git --version
git version 2.4.0

[root@laoyang git-2.4.0]# java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

[root@laoyang git-2.4.0]# find / -name "pip3"
/usr/bin/pip3
/usr/local/python3/bin/pip3

步骤1:安装 Rally
pip3 install esrally

步骤2:配置 Rally
调用: esrally configure 会提示让你输入 java8.home(也就是JAVA_HOME设定的环境变量路径)。 
仅java8.home使用自己本机的JAVA_HOME环境变量路径,其他采用默认值即可。

[root@laoyang .rally]# cat /root/.rally/rally.ini
[meta]
config.version = 5

[system]
root.dir = /root/.rally/benchmarks
log.root.dir = logs
env.name = local

[source]
local.src.dir=/root/.rally/src   #注意,此路径并非elaticsearch安装路径。
remote.repo.url=https://github.com/elastic/elasticsearch.git

[provisioning]
local.install.dir = install

[runtime]
java8.home = /opt/jdk1.8.0_91  #注意,JAVA_HOME 路径为:/opt/jdk1.8.0_91

[benchmarks]
local.dataset.cache = ${system:root.dir}/data

[reporting]
datastore.type = elaticsearch
datastore.host = 10.0.1.30
datastore.port = 9200
datastore.secure = False
datastore.user =
datastore.password =

[tracks]
default.url = https://github.com/elastic/rally-tracks

步骤3:运行esrally
由于elasticsearch的运行必须非root账户。esrally建议用非root账户执行。

3、esrally执行常见问题及解决方案
问题1:版本用哪个版本?
目前用最新版本 Rally 0.3.2(2016-8-7发行)。

问题2:注意gradle需要2.13版本,高版本会不兼容。
[root@laoyang caches]# ll /usr/bin/gradle 
lrwxrwxrwx 1 root root 27 Aug 5 17:13 /usr/bin/gradle -> /opt/gradle-2.13/bin/gradle

问题3:安装时候提示 documents.json.bz2 无法下载成功。
1)手动下载: http://benchmarks.elasticsearch.org.s3.amazonaws.com/corpora/geonames/documents.json.bz2
2)移动到 /root/.rally/benchmarks/data/geonames/(对于root用户)
对于非root用户,elaticsearch用户,移动路径为:/home/elasticsearch/benchmarks/data/geonames/

问题4: esrally单独运行和加参数运行区别?
esrally单独运行:非常方便的指令,等价于 :esrally –pipeline=from-sources –version=current. Rally 将要通过Gradle从源码编译elasticsearch。 
esrally –pipline=from-distribution –distribution-version=2.3.4, Rally将要从 https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.4/elasticsearch-2.3.4.tar.gz

下载elaticsearch2.3.4版本运行。

问题5: Could not resolve all dependencies for configuration ‘:benchmarks:classpath’.
37 > Could not download shadow.jar (com.github.jengelman.gradle.plugins:shadow:1.2.3)如何解决? 
root账户下:

cd /home/elasticsearch/.rally/benchmarks/src 
gradle :distribution:tar:assemble

正确提示信息为:

deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:modules:transport-netty4:processResources UP-TO-DATE
:modules:transport-netty4:classes
:modules:transport-netty4:jar
:modules:transport-netty4:copyPluginPropertiesTemplate
:modules:transport-netty4:pluginProperties
:modules:transport-netty4:bundlePlugin
:distribution:buildModules
:distribution:tar:buildTar
:distribution:tar:generatePomFileForNebulaPublication
:distribution:tar:signArchives SKIPPED
:distribution:tar:assemble

BUILD SUCCESSFUL

4、esrally最终运行结果:
Preparing for race (might take a few moments) ...
  Building from sources ...
/home/elasticsearch/.rally/benchmarks/races/2016-08-08-07-29-59/local/logs/rally_out.logRacing on track [geonames] and challenge [append-no-conflicts] with car [defaults]
  Benchmarking indexing at 12183.1 docs/s [100% done]
  Benchmarking stats (warmup iteration 100/100) [100% done]
  Benchmarking stats (iteration 100/100) [100% done]
  Benchmarking search (warmup iteration 100/100) [100% done]
  Benchmarking search (iteration 100/100) [100% done]
------------------------------------------------------
  _______ __ _____
  / ____(_)___ ____ _/ / / ___/_________ ________
  / /_ / / __ \/ __ `/ / \__ \/ ___/ __ \/ ___/ _ \
 / __/ / / / / / /_/ / / ___/ / /__/ /_/ / / / __/
/_/ /_/_/ /_/\__,_/_/ /____/\___/\____/_/ \___/
------------------------------------------------------
| Metric | Value |
|----------------------------------------------------------:|----------:|
| Min Indexing Throughput [docs/s] | 11949 |
| Median Indexing Throughput [docs/s] | 12307 |
| Max Indexing Throughput [docs/s] | 13349 |
| Indexing time [min] | 164.045 |
| Merge time [min] | 32.3815 |
| Refresh time [min] | 8.82333 |
| Flush time [min] | 1.63852 |
| Merge throttle time [min] | 1.45482 |
| Query latency default (90.0 percentile) [ms] | 68.8676 |
| Query latency default (99.0 percentile) [ms] | 77.6009 |
| Query latency default (100 percentile) [ms] | 78.8328 |
| Query latency term (90.0 percentile) [ms] | 4.63227 |
| Query latency term (99.0 percentile) [ms] | 10.9506 |
| Query latency term (100 percentile) [ms] | 13.0573 |
| Query latency phrase (90.0 percentile) [ms] | 6.35018 |
| Query latency phrase (99.0 percentile) [ms] | 13.1745 |
| Query latency phrase (100 percentile) [ms] | 14.2399 |
| Query latency country_agg_uncached (90.0 percentile) [ms] | 361.913 |
| Query latency country_agg_uncached (99.0 percentile) [ms] | 384.75 |
| Query latency country_agg_uncached (100 percentile) [ms] | 392.645 |
| Query latency country_agg_cached (90.0 percentile) [ms] | 7.71451 |
| Query latency country_agg_cached (99.0 percentile) [ms] | 17.4704 |
| Query latency country_agg_cached (100 percentile) [ms] | 18.4851 |
| Query latency scroll (90.0 percentile) [ms] | 50.4234 |
| Query latency scroll (99.0 percentile) [ms] | 50.9866 |
| Query latency scroll (100 percentile) [ms] | 51.2115 |
| Query latency expression (90.0 percentile) [ms] | 482.02 |
| Query latency expression (99.0 percentile) [ms] | 485.951 |
| Query latency expression (100 percentile) [ms] | 491.999 |
| Query latency painless_static (90.0 percentile) [ms] | 890.382 |
| Query latency painless_static (99.0 percentile) [ms] | 918.354 |
| Query latency painless_static (100 percentile) [ms] | 927.282 |
| Query latency painless_dynamic (90.0 percentile) [ms] | 968.908 |
| Query latency painless_dynamic (99.0 percentile) [ms] | 1019.14 |
| Query latency painless_dynamic (100 percentile) [ms] | 1021.97 |
| Median CPU usage (index) [%] | 887.7 |
| Median CPU usage (stats) [%] | 94.9 |
| Median CPU usage (search) [%] | 445.05 |
| Total Young Gen GC [s] | 89.121 |
| Total Old Gen GC [s] | 12.274 |
| Index size [GB] | 3.30111 |
| Totally written [GB] | 20.2123 |
| Heap used for segments [MB] | 21.6794 |
| Heap used for doc values [MB] | 0.113129 |
| Heap used for terms [MB] | 20.0574 |
| Heap used for norms [MB] | 0.0761719 |
| Heap used for points [MB] | 0.770404 |
| Heap used for stored fields [MB] | 0.6623 |
| Segment count | 96 |
| Indices Stats(90.0 percentile) [ms] | 11.5116 |
| Indices Stats(99.0 percentile) [ms] | 14.1724 |
| Indices Stats(100 percentile) [ms] | 36.8348 |
| Nodes Stats(90.0 percentile) [ms] | 11.342 |
| Nodes Stats(99.0 percentile) [ms] | 13.435 |
| Nodes Stats(100 percentile) [ms] | 16.4768 |

Logs for this race are archived in /home/elasticsearch/.rally/benchmarks/races/2016-08-08-07-29-59/local/logs-geonames-append-no-conflicts-defaults.zip
1
5、问题大讨论
https://discuss.elastic.co/t/the-below-bugs-appers-when-running-esrally/57063/25

源码 作者danielmitterdorfer一一回复, 最终作者回复: 
I am very happy too and I am glad you had so much persistence. You also uncovered a few usability problems that I need to tackle. 
帮作者提了一些建议,促使他升级了一个版本0.3.2。

参考:https://github.com/elastic/rally
--------------------- 
作者:铭毅天下 
来源:CSDN 
版权声明:本文为博主原创文章,转载请附上博文链接!
相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
20天前
|
前端开发 测试技术 Python
【Selenium全攻略】掌握这一工具,实现自动化测试的所有梦想
本文分享了使用Selenium进行UI自动化测试的全过程,包括开发环境部署、代码实现、思路分析和难点解析。作者通过一个实际案例,讲述了如何利用Selenium处理前端生成报告失败的问题,以及在UI自动化中定位元素和处理元素不唯一的情况。同时,文章强调了解决问题思路的重要性,鼓励读者开拓思维,寻找不同的解决方案。
68 4
【Selenium全攻略】掌握这一工具,实现自动化测试的所有梦想
|
22天前
|
前端开发 jenkins 测试技术
自动化测试介绍,为何 Apifox 是进行自动化测试的最佳工具
自动化测试利用专用软件执行测试用例,比手动测试更高效准确。Apifox是一款集API文档、调试与自动化测试于一体的工具,提供一体化解决方案,简化API变更管理。其强大的测试功能支持丰富的断言及测试场景组合,便于模拟真实业务流程。Apifox还提供详尽的测试报告与分析功能,有助于快速定位问题。此外,它能轻松集成到CI/CD流程中,并支持定时任务及多分支管理,极大提升了测试效率和团队协作。相较于其他工具,Apifox以其全面的功能和友好的界面脱颖而出。
|
8天前
|
存储 SQL 缓存
数据库测试|Elasticsearch和ClickHouse的对决
由于目前市场上主流的数据库有许多,这次我们选择其中一个比较典型的Elasticsearch来和ClickHouse做一次实战测试,让大家更直观地看到真实的比对数据,从而对这两个数据库有更深入的了解,也就能理解为什么我们会选择ClickHouse。
数据库测试|Elasticsearch和ClickHouse的对决
|
24天前
|
网络协议 Java API
SpringBoot整合Elasticsearch-Rest-Client、测试保存、复杂检索
这篇文章介绍了如何在SpringBoot中整合Elasticsearch-Rest-Client,并提供了保存数据和进行复杂检索的测试示例。
SpringBoot整合Elasticsearch-Rest-Client、测试保存、复杂检索
|
10天前
|
安全 Linux 测试技术
Kali Linux预装的自动化渗透测试工具
Kali Linux预装的自动化渗透测试工具
20 2
|
13天前
|
测试技术
基于LangChain手工测试用例转Web自动化测试生成工具
该方案探索了利用大模型自动生成Web自动化测试用例的方法,替代传统的手动编写或录制方式。通过清晰定义功能测试步骤,结合LangChain的Agent和工具包,实现了从功能测试到自动化测试的转换,极大提升了效率。不仅减少了人工干预,还提高了测试用例的可维护性和实用性。
25 4
|
17天前
|
消息中间件 Kafka 测试技术
【Azure 事件中心】使用Kafka的性能测试工具(kafka-producer-perf-test)测试生产者发送消息到Azure Event Hub的性能
【Azure 事件中心】使用Kafka的性能测试工具(kafka-producer-perf-test)测试生产者发送消息到Azure Event Hub的性能
|
21天前
|
测试技术 API
软件测试:Postman 工具的使用。开发及测试均需要掌握的测试工具
这篇文章详细介绍了Postman工具的各个模块功能,包括创建请求、集合、环境、自动化测试等,并解释了如何使用Postman进行GET、POST、PUT和DELETE等常见HTTP请求的测试。
|
27天前
|
网络协议 测试技术 Apache
测试Netty高并发工具
测试Netty高并发工具
52 3
|
26天前
|
人工智能 自然语言处理 测试技术
基于LangChain手工测试用例转接口自动化测试生成工具
本文介绍利用大语言模型自动生成接口自动化测试用例的方法。首先展示传统通过HAR文件生成测试用例的方式及其局限性,随后提出结合自然语言描述的测试需求与HAR文件来生成更全面的测试脚本。通过LangChain框架,设计特定的提示词模板,使模型能够解析测试需求文档和HAR文件中的接口信息,并据此生成Python pytest测试脚本。示例展示了正常请求、非法请求及无效路径三种测试场景的自动化脚本生成过程。最终,整合流程形成完整代码实现,帮助读者理解如何利用大模型提高测试效率和质量。
61 2