您的位置:首页 > 其它

ElasticSearch写入性能优化

2018-05-17 22:56 309 查看

参考文章:
1. 将 ELASTICSEARCH 写入速度优化到极限
2. Mastering Elasticsearch(中文版)
3. How to Maximize Elasticsearch Indexing Performance (Part 1)
4. How to Maximize Elasticsearch Indexing Performance (Part 2)
5. How to Maximize Elasticsearch Indexing Performance (Part 3)

背景:

  1. ES读取文件入库速度比其它系统写文件速度慢,导致文件大量堆积
  2. ES入库方式采取:python调用ElasticSearch的bulk接口实现数据的批量插入

尝试的优化方案

方案一

创建更多的python子进程去读取文件

方案二

将读写的文件目录挂载内存文件系统

方案三

修改ElasticSearch的配置文件ElasticSearch.yml(Elasticsearch的配置文件在/etc/elasticsearch/)
1. 导入大量数据 index.refresh_interval: 30
2. 去掉副本 index.number_of_replicas: 0
3. 机械硬盘并发访问问题index.merge.scheduler.max_thread_count: 1
4. 如果系统可以接受一定几率的数据丢失,调整 translog 持久化策略为周期性和一定大小的时候 flush:
* index.translog.durability: async
* index.translog.sync_interval: 120s
* index.translog.flush_threshold_size: 1024mb
* index.translog.flush_threshold_period: 120m

方案四

修改ElasticSearch.yml配置文件

bootstrap.mlockall:true

设置为true来锁住内存。

因为当jvm开始swapping时es的效率会降低,所以要保证它不swap。

[root@timeserver ~]# vim /etc/sysctl.conf
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296
vm.swappiness=10
[root@timeserver ~]# sysctl -p

方案五

用性能更好的硬件

用ssd替换机械硬盘,可取消ElasticSearch.yml里关于机械硬盘并发访问的修改

关于cpu有大佬测试数据如下:

2650的 CPU 上压了一下写入性能,2.5k,70个字段的 doc 可以跑到4.5w/s

相同的数据,2430只能跑到1.3w/s

方案六

文件属性特征的影响

对于每个字段如果都使用分词插件去做语义分析,也会大量消耗cpu

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: