ElasticSearchã®ã¤ã³ãã¯ã·ã³ã°ãé«éåãã
諸äºæ ã§ElasticSearchã®äºã°ã£ããæ¸ãã¦ã¾ãããSolrã®æ¹ã好ãã§ãã
ElasticSearchã®ã¤ã³ãã¯ã·ã³ã°ãé«éåããããã«ãã£ãäºãæ®ãã¦ããã¾ãã
åºæ¬çã«ã¯âã«æ¸ãã¦ãããã¨ã°ããã§ãã
Performance Considerations for Elasticsearch Indexing | Elastic
ãã¼ã¿æå ¥æ¹æ³
ãã¼ã¿ã®æå ¥ã«ã¯Bulk APIã使ãã¾ãã ãªããå ¬å¼ã§ã¯1ã¤ã®bulk Importã®ãµã¤ãºã¯5~15MBã«ãããã¨ãæ¨å¥¨ãã¦ãã¾ãã
curl -XPOST http://localhost:9200/_bulk --data-binary @databatch.json >/dev/null
ã¡ã¢ãªé¢ä¿
ES_HEAP_SIZEã«å®ã¡ã¢ãªã®ååç¨åº¦ãå²ãå½ã¦ãmlockall:trueã§ElasticSearchã®ã¡ã¢ãªãã¹ã¯ããããªãããã«ãã¾ããåã®è¨äºã§æ¸ãã¦ãã®ã§ã詳細ã¯ãã¡ãã§ã
ElasticSearchでmlockall:trueが効かない時にチェックすること - サナギわさわさ.json
ã¬ããªã«ã·ã£ã¼ãã0ã«è¨å®
巨大ã¤ã³ããã¯ã¹ä½æä¸ã¯ã¬ããªã«ã·ã£ã¼ããä½ããªãããã«ãããã¨ã§ãã¤ã³ããã¯ã¹ä½æã«ãããæéãå²ã¨çããªãã¾ããã¤ã³ããã¯ã¹ä½æå¾ã«å¥½ããªã ãä½ã£ã¦ãã ããã
curl -XPUT http://localhost:9200/index_name/_settings -d ' { "index" : { "number_of_replicas" : 0 } }'
ã³ãããã®é »åº¦ãå¤æ´
ElasticSearchã¯NRT(Near Real-Time Search)æ©è½ãæè¼ãã¦ãããããã©ã«ãã§1sãã¨ã«ã½ããã³ããããå®è¡ãããæ´æ°çµæãæ¤ç´¢ã«åæ ããã¾ãã巨大ã¤ã³ããã¯ã¹ãä½æããéã«ã¯ãããçµæ§éããããã¤ã³ãã¯ã·ã³ã°ä¸ã«æ´æ°çµæãããã¾ã§ãªã¢ã«ã¿ã¤ã ã«åæ ããå¿
è¦ããªãå ´åã¯ãã½ããã³ãããã®é »åº¦ã¯30sãããã«è¨å®ããæ¹ãæ©ããªãã¾ãã
â»sãã¤ããªãã¨msecã«ãªã£ã¦ãã¾ãã®ã§æ³¨æ
curl -XPUT http://localhost:9200/index_name/_settings -d ' { "index" : { "refresh_interval" : "30s" } }'
ã¾ãããããå¦çãçµããã¾ã§æ´æ°çµæãåæ ãããå¿ è¦ããªãããã¤ãã®éä»ããæ´æ°å¦çãããªãäºãä¿è¨¼ã§ãããªãã-1ã«è¨å®ããã°ã½ããã³ããããèªåã§è¡ãããªããªãã¾ãã
curl -XPUT http://localhost:9200/index_name/_settings -d ' { "index" : { "refresh_interval" : -1 } }'
_allãã£ã¼ã«ããç¡å¹å
ã¤ã³ãã¯ã·ã³ã°ãããã¼ã¿ã¯å ¨ã¦_allãã£ã¼ã«ãã«ãå ¥ãã¾ããå¿ è¦ãªãå ´åã¯mappingã®éã«ç¡å¹åãããã¨ã§ãã¤ã³ãã¯ã·ã³ã°ãæ©ããªãã¾ãã
{ "person" : { "_all" : {"enabled" : false}, "properties" : { } } }
ã¤ã³ãã¯ã·ã³ã°ãçµãã£ãå¾
ã¤ã³ãã¯ã·ã³ã°ãçµãã£ãå¾ã¯optimizeãè¡ããã¬ããªã«ã·ã£ã¼ãã好ããªå¤ã«è¨å®ãã¦ãã ããã
curl -XPOST 'http://localhost:9200/index_name/_optimize' curl -XPUT http://localhost:9200/index_name/_settings -d ' { "index" : { "number_of_replicas" : 1 } }'
ä»ã«ããã¼ãã³ãããã®é »åº¦ï¼translog.flush_threshold_sizeï¼ãã_sourceã®ç¡å¹åããindices.memory.index_buffer_sizeã®è¨å®ãªã©ããã¥ã¼ãã³ã°ãããã¤ã³ãã¯ããã¨æãã®ã§ããã ä»åã¯èªåã®ç°å¢ã§å¹æãæãããã®ã ãç´¹ä»ãã¾ããã
å ¬å¼ã§ã¯22k/secãããã®é度ãåºãã¨è¨ããã¦ããæ°ãããã®ã§ãããRAM:8GBã®ES_HEAP_SIZE:4GBç°å¢ã§ã¯1å件ã®ç»é²ã§8k/secãããããåºã¾ããã§ãããããå°ãæ©ãã§ãããã¾ãè¨é²ãè¼ãããã¨æãã¾ãã