0%

写入优化

elasticsearch6.x写入优化

translog 调整

默认的配置是

1
2
3
4
5
6
7
8
9
10
11
12
13
"index":{
"translog": {
"generation_threshold_size": "64mb",
"flush_threshold_size": "512mb",
"sync_interval": "5s",
"retention": {
"size": "512mb",
"age": "12h"
},
"durability": "REQUEST"
}
}

也就是说每个请求都会进行flush,这样保证了数据不会丢失,但是写入性能会很差,可以设置为异步,持久化策略为周期性和一定大小的时候flush

1
2
3
4
5
6
"index": {
"translog": {
"sync_interval": "60s",
"durability": "async"
}
}

这样就调整为60s(sync_interval)刷新一次或者当超过512m(flush_threshold_size)进行刷新