Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Elasticsearch5.0.0で再インデクシングの高速化を探究した話

mwatanabe
September 15, 2016

 Elasticsearch5.0.0で再インデクシングの高速化を探究した話

第17回Elasticsearch勉強会の発表資料

mwatanabe

September 15, 2016
Tweet

More Decks by mwatanabe

Other Decks in Technology

Transcript

  1. αΠϘ΢ζ w ৘ใڞ༗8FCΞϓϦέʔγϣϯ άϧʔϓ΢ΣΞ ͷ։ൃ w DZCP[VDPNͱ͍͏Ϋϥ΢υαʔϏεΛఏڙ w ݕࡧγεςϜ͸ओʹશจݕࡧͱͯ͠ར༻ w

    ҰͭͷϓϩμΫτͷଉ͕௕͍ w ݕࡧγεςϜͷόʔδϣϯΞοϓ΍τʔΫφΠβมߋͰ ࠶ΠϯσΫγϯάʹ͕͔͔࣌ؒΔͷ͕ͭΒ͔ͬͨ 
  2. #VML"1* w υΩϡϝϯτͷߋ৽΍࡟আΛϦΫΤετͰෳ਺࣮ߦՄೳ w BDUJPO@BOE@NFUB@EBUBͷߦͱPQUJPOBM@TPVSDFͷߦΛ࿈ ଓͯ͠ॻ͘ w ࠓճ͸ෳ਺ߋ৽ͳͷͰɺJOEFYBDUJPOͱTPVSDFΛଓ͚Δ  $

    curl -XPOST ‘es-watanabe-1:9200/_bulk’ -d ' { "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } } { "field1" : "value1" } { "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } } { "field1" : "value2" } { "index" : { "_index" : "test", "_type" : "type1", "_id" : "3" } } { "field1" : "value3" } '
  3. Ϋϥελߏ੒ w ҎԼͷεϖοΫͷϚγϯ୆ͷΫϥελ w &MBTUJDTFBSDIͷόʔδϣϯ͸BMQIB  ཁૉ ੑೳ උߟ $16

    ()[ DPSF UISFBET .FNPSZ (# &MBTUJDTFBSDIͷYNY͸(# )%%TFRXSJUF .#T EEͰ؆қܭଌ )%%TFRSFBE .#T IEQBSNͰ؆қܭଌ /FUXPSL (CQT JQFSGͰܭଌ 04 6CVOUV ˞)%%TFRXSJUF͸3"*%ͷޮՌ౳Ͱߴ଎ʹಈ࡞͍ͯ͠ΔΑ͏ʹݟ͑·͕͢ɺ ࣮ࡍ͸ϥϯμϜϥΠτͩͬͨΓͰ͜Μͳ਺ࣈ͸Ͱͳ͍ͷͰɺࢀߟఔ౓ʹߟ͍͑ͯͩ͘͞ɻ
  4. NBQQJOHTTFUUJOHT w @BMMEJTBCMF w ϨϓϦΧ਺ w γϟʔυ਺ w SFGSFTI@JOUFSWBM w

    JOEFYNFSHFTDIFEVMFSNBY@UISFBE@DPVOU  DGIUUQTXXXFMBTUJDDPHVJEFFOFMBTUJDTFBSDIHVJEFDVSSFOUJOEFYJOHQFSGPSNBODFIUNM
  5. NBQQJOHTTFUUJOHT  { "settings": { "number_of_replicas": 0, "number_of_shards": 16, "index.refresh_interval":

    "-1", "index.merge.scheduler.max_thread_count" : 1 }, "mappings": { "_default_": { "_all": {"enabled": false } } } }
  6. DBUUISFBE@QPPM"1* $ curl 'es-watanabe-1:9200/_cat/thread_pool? v&h=id,host,bt,ba,bq,bs,bc,st,sa,sq,ss,sc' id host bt ba bq

    bs bc st sa sq ss sc vM4E es-watanabe-1 fixed 0 0 24 288 fixed 0 0 37 584 btge es-watanabe-2 fixed 0 0 24 13524 fixed 0 0 37 24143 zPof es-watanabe-3 fixed 0 0 24 13497 fixed 0 0 37 24115 3y0A es-watanabe-4 fixed 0 0 24 13609 fixed 0 0 37 24226 IyM- es-watanabe-5 fixed 0 0 24 12979 fixed 0 0 37 24616 iXmJ es-watanabe-6 fixed 0 0 24 13538 fixed 0 0 37 25176 iBLd es-watanabe-7 fixed 0 0 24 13388 fixed 0 0 37 25029 cKjt es-watanabe-8 fixed 0 0 24 13539 fixed 0 0 37 25173 CUCVMLUZQF CBCVMLBDUJWF CRCVMLRVFVF CTCVMLTJ[F CDCVMLDPNQMFUFE TUTFBSDIUZQF TBTFBSDIBDUJWF TRTFBSDIRVFVF TTTFBSDITJ[F TDTFBSDIDPNQMFUFE
  7. DBUUISFBE@QPPM"1* $ curl 'es-watanabe-1:9200/_cat/thread_pool? v&h=id,host,bt,ba,bq,bs,bc,st,sa,sq,ss,sc' id host bt ba bq

    bs bc st sa sq ss sc vM4E es-watanabe-1 fixed 0 0 24 288 fixed 0 0 37 584 btge es-watanabe-2 fixed 0 0 24 13524 fixed 0 0 37 24143 zPof es-watanabe-3 fixed 0 0 24 13497 fixed 0 0 37 24115 3y0A es-watanabe-4 fixed 0 0 24 13609 fixed 0 0 37 24226 IyM- es-watanabe-5 fixed 0 0 24 12979 fixed 0 0 37 24616 iXmJ es-watanabe-6 fixed 0 0 24 13538 fixed 0 0 37 25176 iBLd es-watanabe-7 fixed 0 0 24 13388 fixed 0 0 37 25029 cKjt es-watanabe-8 fixed 0 0 24 13539 fixed 0 0 37 25173 CUCVMLUZQF CBCVMLBDUJWF CRCVMLRVFVF CTCVMLTJ[F CDCVMLDPNQMFUFE TUTFBSDIUZQF TBTFBSDIBDUJWF TRTFBSDIRVFVF TTTFBSDITJ[F TDTFBSDIDPNQMFUFE CVML༻ͷεϨου͸࠷େͰ·Ͱಉ࣮࣌ߦՄೳ
  8. 3FJOEFY"1* w 4DSPMM4J[FΛม࣮͑ͯߦ଎౓Λൺֱ w ҎԼͷίϚϯυΛΫϥελ֎ͷϚγϯ্Ͱ࣮ߦ  $ curl -X POST

    'es-watanabe-1:9200/_reindex' -d '{ "source":{"index":"src", "size": 1000}, "dest" :{"index":"dest"} }'
  9. 3FJOEFY"1* w ࠷଎Ͱ໿ඵ w $166TBHF਺ˋ w σΟεΫॻ͖ࠐΈ਺.# w DBUUISFBE@QPPMͷCVMLBDUJWF͸ ɺఔ౓

    w ಺෦Ͱ͸4DSPMM"1*ͱ#VML"1*Λ ஞ࣍తʹ࣮ߦ  4DSPMM4J[F ࣮ߦ࣌ؒ   ඵ   ඵ   ඵ   ඵ   ඵ
  10. 3FJOEFY"1* w ࠷଎Ͱ໿ඵ w $166TBHF਺ˋ w σΟεΫॻ͖ࠐΈ਺.# w DBUUISFBE@QPPMͷCVMLBDUJWF͸ ɺఔ౓

    w ಺෦Ͱ͸4DSPMM"1*ͱ#VML"1*Λ ஞ࣍తʹ࣮ߦ  4DSPMM4J[F ࣮ߦ࣌ؒ   ඵ   ඵ   ඵ   ඵ   ඵ Ϧιʔε΋ͬͱ࢖͍౗ͤΔ͸ͣ
  11. 4DSPMM"1*ͱ#VML"1*ͷผεϨουԽ w ஗͘ͳͬͨʂ w ࠷଎Ͱ໿ඵ w Ϧιʔε࢖༻ྔ͸3FJOEFY"1*ͱେࠩແ͠ w πʔϧಋೖʹΑΔෛՙ͕ฒྻԽͷϝϦο τΛେ෯ʹ্ճΔ

    w ·ͩ߄ͯΔ࣌ؒͰ͸ͳ͍  4DSPMM4J[F ࣮ߦ࣌ؒ   ඵ   ඵ   ඵ   ඵ &MBTUJDTFBSDI͔Β෼཭ͨ͜͠ͱͰ
 "1*ͷฒྻ࣮ߦͳͲ͸͠΍͘͢ͳͬͨ
  12. #VML"1*ͷฒྻԽ w UISFBE@QPPMͰCVMLBDUJWF͸͕."9 w ࣮ࡍʹ͸ ఔ౓͔͠࢖͍͑ͯͳ͍ w #VML"1*ΑΓ͸4DSPMM"1*ͷํ͕ॲཧ͕ૣ͍ɻ
 ͭ·ΓɺΩϡʔʹ͸ະॲཧͷυΩϡϝϯτ͕ཷ·Δ w

    #VML"1*ͷϦΫΤετͰCVMLBDUJWFͷεϨου͸ɺϊʔυ಺ͷ γϟʔυ਺·Ͱ૿͑ΔՄೳੑ͕͋Δ w TIBSEOPEFͳͷͰɺBDUJWFUISFBETCVMLBQJSFRVFTU w CVMLBDUJWF͸͕."9ͳͷͰɺഒ͸ฒྻʹ࣮ߦͯ͠΋ྑͦ͞͏ 
  13. #VML"1*ͷฒྻԽ w ࠷଎Ͱඵʢ3FJOEFY"1*ͷ໿ഒ଎ʣ w 4DSPMM"1*ͱ#VML"1*Λड͚෇͚ΔϊʔυͰ͸ఔ౓ͷ$16࢖༻཰ w ͦΕҎ֎ͷϊʔυ͸ఔ౓ͷ$16࢖༻཰ w σΟεΫॻ͖ࠐΈ͸ʙ.#T w

    UISFBEQPPMͷCVMLBDUJWF͸ʹಧ͔ͳ͍ఔ౓  #VMLฒྻ౓ #VML4J[F 4DSPMM4J[F ࣮ߦ࣌ؒ    ඵ    ඵ    ඵ    ඵ    ඵ    ඵ
  14. #VML"1*ͷฒྻԽ w ࠷଎Ͱඵʢ3FJOEFY"1*ͷ໿ഒ଎ʣ w 4DSPMM"1*ͱ#VML"1*Λड͚෇͚ΔϊʔυͰ͸ఔ౓ͷ$16࢖༻཰ w ͦΕҎ֎ͷϊʔυ͸ఔ౓ͷ$16࢖༻཰ w σΟεΫॻ͖ࠐΈ͸ʙ.#T w

    UISFBEQPPMͷCVMLBDUJWF͸ʹಧ͔ͳ͍ఔ౓  #VMLฒྻ౓ #VML4J[F 4DSPMM4J[F ࣮ߦ࣌ؒ    ඵ    ඵ    ඵ    ඵ    ඵ    ඵ Ϧιʔεతʹ͸
 ·ͩ·͍͚ͩͦ͏
  15. 4MJDFE4DSPMM w εφοϓγϣοτऔಘ࣌ʹTMJDFͷJEΛࢦఆ͢Δ w TMJDF਺͸NBYύϥϝʔλͰࢦఆ͢Δ w TMJDF਺͕ͷ৔߹ɺTMJDFͱTMJDFΛผεϨουͰѻ͏͜ͱͰฒྻԽՄೳ  # Thread1

    curl -XGET 'localhost:9200/src/_search?scroll=1m' -d '{ "slice": { "id": 0, "max": 2 } }' # Thread2 curl -XGET 'localhost:9200/src/_search?scroll=1m' -d '{ "slice": { "id": 1, "max": 2 } }'
  16. 4DSPMM"1*ͷฒྻԽ w 4MJDFE4DSPMMʹΑΓɺ4DSPMM"1* Λฒྻʹ࣮ߦՄೳ w 4MJDF਺͸ #VMLฒྻ౓͸ͱ ͯ͠ #VML4J[F 4DSPMM4J[FΛมԽ

    ͤͯ͞ܭଌ w 4MJDF਺͸TIBSE਺ΑΓ૿΍͢ͱ஗ ͘ͳΔͱ͍͏ϦϑΝϨϯεʹै͍ɺ TIBSE਺ͷಉ਺ͷͰݻఆ 
  17. 4DSPMM"1*ͷฒྻԽ w ࠷଎Ͱඵʢ3FJOEFY"1*ͷ໿ഒ଎ʣ w 4DSPMM"1*ͱ#VML"1*Λड͚෇͚ΔϊʔυͰ͸ఔ౓ͷ$16࢖༻཰ w ͦΕҎ֎ͷϊʔυ͸ఔ౓ͷ$16࢖༻཰ w σΟεΫॻ͖ࠐΈ͸ʙ.#T w

    UISFBEQPPMͷCVMLBDUJWF͸ʹಧ͔ͳ͍ఔ౓  #VMLฒྻ౓ #VML4J[F 4MJDF਺ 4DSPMM4J[F ࣮ߦ࣌ؒ     ඵ     ඵ     ඵ     ඵ
  18. 4DSPMM"1*ͷฒྻԽ w ࠷଎Ͱඵʢ3FJOEFY"1*ͷ໿ഒ଎ʣ w 4DSPMM"1*ͱ#VML"1*Λड͚෇͚ΔϊʔυͰ͸ఔ౓ͷ$16࢖༻཰ w ͦΕҎ֎ͷϊʔυ͸ఔ౓ͷ$16࢖༻཰ w σΟεΫॻ͖ࠐΈ͸ʙ.#T w

    UISFBEQPPMͷCVMLBDUJWF͸ʹಧ͔ͳ͍ఔ౓  #VMLฒྻ౓ #VML4J[F 4MJDF਺ 4DSPMM4J[F ࣮ߦ࣌ؒ     ඵ     ඵ     ඵ     ඵ ଎͘͸ͳ͕ͬͨ
 Ϧιʔεతʹ͸େࠩͳ͠
  19. 3FJOEFY5PPMͷ෼ࢄ࣮ߦ w ࠷଎Ͱඵʢ3FJOEFY"1*ͷ໿ഒ଎ʣ w ʙఔ౓ͷ$16࢖༻཰ w σΟεΫॻ͖ࠐΈ͸ʙ.#T w UISFBEQPPMͷCVMLBDUJWF͸΄΅Λࣔ͢ 

    #VMLฒྻ౓ #VML4J[F 4MJDF਺ 4DSPMM4J[F ࣮ߦ࣌ؒ     ඵ     ඵ     ඵ
  20. 3FJOEFY5PPMͷ෼ࢄ࣮ߦ w ࠷଎Ͱඵʢ3FJOEFY"1*ͷ໿ഒ଎ʣ w ʙఔ౓ͷ$16࢖༻཰ w σΟεΫॻ͖ࠐΈ͸ʙ.#T w UISFBEQPPMͷCVMLBDUJWF͸΄΅Λࣔ͢ 

    #VMLฒྻ౓ #VML4J[F 4MJDF਺ 4DSPMM4J[F ࣮ߦ࣌ؒ     ඵ     ඵ     ඵ ଎͘ͳͬͨ͠
 Ϧιʔε΋࢖͍౗ͤͯΔʂ
  21. υΩϡϝϯτΛഒʹෳ੡ w ࠷଎Ͱඵ w ໿.#TʢສઍEPDTTʣఔ౓ͷ଎౓ w (#T΋ݟ͖͑ͯͯເ͕޿͕Δ w )%%ͰͷϚγϯͰͷສυΩϡϝϯτͷ࣮ߦ࣌ؒ͸ඵͩͬ ͨͷͰɺ44%ԽͰഒ͙Β͍଎͘ͳͬͨ

     γϟʔυ਺ #VMLฒྻ౓ #VML4J[F 4MJDF਺ 4DSPMM4J[F ࣮ߦ࣌ؒ      ඵ      ඵ      ඵ      ඵ
  22. ࣮ߦ࣌ؒൺֱ ߏ੒ ࣮ߦ଎౓ ଎౓ഒ཰ 3FJOEFY"1* ඵ  4DSPMM"1*ͱ#VML"1*ΛผεϨουԽ ඵ 

    #VML"1*ΛฒྻԽ ඵ  4DSPMM"1*ΛฒྻԽ ඵ  3FJOEFY5PPMͷ෼ࢄ࣮ߦ ඵ  44%Λ࢖͏ ඵ  w #VML"1*ͷฒྻԽɺ3FJOEFY5PPMͷ෼ࢄ࣮ߦͷޮՌ͕ߴ͍ w ϊʔυ૿΍ͤ͹εέʔϧ͢Δ3FJOEFY5PPMͷ෼ࢄ࣮ߦ͕͓͢͢Ί w #VML"1*ͷฒྻԽ͕Ͱ͖Ε͹4DSPMM"1*ͷฒྻԽ΋େͨ͠खؒͰ ͸ͳ͍ͷͰɺ࠷ޙͷ٧ΊʹͲ͏ͧ  ˞্͔ΒॱʹྦྷੵͰվળΛద༻͍ͯ͠·͢
  23. 8FBSFIJSJOH w ΞϓϦέʔγϣϯج൫νʔϜʢେମͳΜͰ΋΍Δ΍ͭΒʣ w ϓϩμΫτ։ൃνʔϜ w 43&νʔϜ w ੜ࢈ੑ޲্νʔϜ w

    ଞʹ΋৭ʑνʔϜ͋Γ·͢ w ΨπΨπ͸ͯ͠ͳ͍͚Ͳಇ͖΍͍͢ͱࢥ͏ʢࢲݟʣ w ͝ڵຯ͋Ε͹࠾༻ϖʔδݟͯΈ͍ͯͩ͘͞
 IUUQDZCP[VDPKQDPNQBOZKPCSFDSVJUNFOUMJTU