ElasticSearch写入性能优化
参考文章:
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)
背景:
- ES读取文件入库速度比其它系统写文件速度慢,导致文件大量堆积
- 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
阅读更多- Elasticsearch写入性能优化
- Elasticsearch写入性能优化
- Elasticsearch写入性能优化
- Elasticsearch写入性能优化
- 将 ELASTICSEARCH 写入速度优化到极限
- ElasticSearch性能优化
- ES索引写入性能优化
- eBay Elasticsearch性能优化实践
- ElasticSearch性能优化方案
- Elasticsearch node节点特点和架构性能优化方法
- ElasticSearch57:内核原理探秘_优化写入流程实现NRT近实时(filesystem cache,refresh)
- Spark2.x写入Elasticsearch的性能测试
- 在elasticsearch里如何高效的使用filter [性能优化必看]
- elasticsearch索引性能优化
- Mysql 批量写入数据 性能优化
- 分布式搜索引擎Elasticsearch性能优化与配置
- Neo4j高级应用技术专题系列 - APOC存储过程库-【3】优化数据库写入性能
- ElasticSearch性能优化官方建议
- Elasticsearch性能优化
- eBay Elasticsearch 性能优化实战-中文篇