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

まさかEC2にインストールなんかしていないよね?~Amazon ESのメリット/デメリット~

まさかEC2にインストールなんかしていないよね?~Amazon ESのメリット/デメリット~

2020/2/7(金)に開催された「Amazon Elasticsearch Service & Open Distro for Elasticsearch Meetup」にて発表した資料です。

NAVITIME JAPAN

February 07, 2020
Tweet

More Decks by NAVITIME JAPAN

Other Decks in Technology

Transcript

  1. ·͔͞EC2ʹΠϯετʔϧͳΜ͔ͯ͠ͳ͍ΑͶʁ
    ʙAmazon ESͷϝϦοτ/σϝϦοτʙ
    גࣜձࣾφϏλΠϜδϟύϯ
    ాத Ұथ

    View full-size slide

  2. Who Am I ?
    ໊લɿాத Ұथ
    ໾ׂɿCloud Architect
    ܦྺɿ2013೥৽ଔೖࣾɻ2017೥ʙΫϥ΢υܥͷ࡞ۀʹैࣄ
    ޷͖ͳAWSαʔϏεɿCloudFormation, Lambda

    View full-size slide

  3. Our Company
    • גࣜձࣾ φϏλΠϜδϟύϯ
    • ઃཱ 2000 ೥ 3 ݄ 1 ೔
    • ۀ຿಺༰
    • φϏήʔγϣϯαΠτɾΞϓϦͷӡӦ։ൃ
    • ௨৴ΧʔφϏήʔγϣϯࣄۀ
    • ܦ࿏୳ࡧΤϯδϯͷϥΠηϯεࣄۀ ͳͲ
    • ैۀһ਺ ໿ 540 ໊ (ΤϯδχΞ 80% Ҏ্ʣ

    View full-size slide

  4. Our Products
    NAVITIME
    ৐׵NAVITIME
    όεNAVITIME
    ͜ΈΕΆ
    ެڞަ௨ υϥΠϒ
    ΧʔφϏλΠϜ
    υϥΠϒαϙʔλʔ
    τϥοΫΧʔφϏ
    πʔϦϯά
    πʔϦϯάαϙʔλʔ
    ࣗసंNAVITIME
    Travel/Inbound
    JapanTravel
    NAVITIME Transit
    NAVITIME Travel
    Plat
    ϔϧεέΞ
    ALKOO
    PC/SP Web

    View full-size slide

  5. Our Products
    Φ΢ϯυϝσΟΞ
    ޿ࠂ / ΞϥΠΞϯε
    ϏδωεφϏλΠϜ
    ಈଶ؅ཧιϦϡʔγϣϯ
    ϏδωεφϏλΠϜ
    ަ௨අਫ਼ࢉύοέʔδ
    ςϨϚςΟΫεαʔϏε
    API / SDK
    ిమɾόεࣄۀऀ޲͚
    ιϦϡʔγϣϯ
    ަ௨ίϯαϧςΟϯά
    ϏδωεφϏλΠϜ
    ަ௨අਫ਼ࢉύοέʔδ
    ϏδωεφϏλΠϜ
    ಈଶ؅ཧιϦϡʔγϣϯ
    ޿ࠂ/ΞϥΠΞϯε Φ΢ϯυϝσΟΞ
    ަ௨ίϯαϧςΟϯά ిమ/όεࣄۀऀ޲͚
    ιϦϡʔγϣϯ
    API / SDK ςϨϚςΟΫεαʔϏε

    View full-size slide

  6. ʲ࿩͢͜ͱʳ
    • Amazon Elasticsearch Serviceͷ؂ࢹ/ӡ༻ํ๏ͷ঺հ
    • EC2্ͰElasticsearchΛߏஙͨ͠ͱ͖ͷ೉఺
    • UltraWarm for Amazon Elasticsearch Serviceʹ͍ͭͯຊ౰ʹগ͠
    ʲ࿩͞ͳ͍͜ͱʳ
    • Elasticsearchࣗମͷઆ໌
    • Elasticsearchࣗମͷվળํ๏

    View full-size slide

  7. φϏλΠϜαʔϏεͱAWS

    View full-size slide

  8. 2013೥ Ŗ
    2015೥ Ŗ
    2016೥ Ŗ
    σʔλ෼ੳج൫ͷҰ෦ΛAWS؀ڥͰߏங։࢝
    ަ௨ίϯαϧςΟϯάࣄۀɺNAVITIME TransitͰAWSར༻։࢝
    φϏλΠϜαʔϏεͷAWSҠߦϓϩδΣΫτελʔτ
    ৐׵NAVITIME͕AWSར༻։࢝
    σʔλ෼ੳج൫ΛAthena+S3ʹҠߦ
    ॱ࣍ɺφϏλΠϜαʔϏεΛAWS؀ڥ΁Ҡߦ
    ܦ࿏୳ࡧΤϯδϯʹAWSͷGPUΛ࠾༻
    ΄΅͢΂ͯͷαʔϏε͕AWS্ͰՔಇ
    2017೥ Ŗ
    2019೥ Ŗ
    φϏλΠϜδϟύϯͷAWSͷ׆༻

    View full-size slide

  9. αʔϏεجຊߏ੒
    υϥΠϒαϙʔλʔ ΞϓϦέʔγϣϯαʔό APIαʔό
    ֤छσʔλ(DB)
    ஍ਤ഑৴αʔό
    ܦ࿏୳ࡧαʔό
    ֤छσʔλ(ES) ֤छσʔλ(Solr)

    View full-size slide

  10. φϏλΠϜαʔϏεͰͷElasticsearch

    View full-size slide

  11. Ͳ͜Ͱ࢖ΘΕͯΔͷʁ

    View full-size slide

  12. Ͳ͜Ͱ࢖ΘΕͯΔͷʁ
    υϥΠϒαϙʔλʔ
    ஍ਤΛ։͘
    • ओʹυϥΠϒܥͷαʔϏεͰٯδΦίʔσΟϯάͷݕࡧͰར༻

    View full-size slide

  13. Ͳ͜Ͱ࢖ΘΕͯΔͷʁ
    υϥΠϒαϙʔλʔ
    ஍ਤΛ։͘ ஍ਤ্Λ௕ԡ͠
    • ओʹυϥΠϒܥͷαʔϏεͰٯδΦίʔσΟϯάͷݕࡧͰར༻

    View full-size slide

  14. Ͳ͜Ͱ࢖ΘΕͯΔͷʁ
    υϥΠϒαϙʔλʔ
    ஍ਤΛ։͘
    • ओʹυϥΠϒܥͷαʔϏεͰٯδΦίʔσΟϯάͷݕࡧͰར༻
    ஍ਤ্Λ௕ԡ͠ ஍఺ͷॅॴ͕දࣔ

    View full-size slide

  15. Ͳ͜Ͱ࢖ΘΕͯΔͷʁ
    • ଞʹ΋ɺNAVITIME TravelͰͷهࣄݕࡧͳͲͰར༻த
    NAVITIME Travel

    View full-size slide

  16. ࣮͸ͣͬͱElasticsearch on EC2ͰՔಇͤͯ͞·ͨ͠ɾɾɾ

    View full-size slide

  17. աڈͷߏ੒
    υϥΠϒαϙʔλʔ ΞϓϦέʔγϣϯαʔό APIαʔό
    ֤छσʔλ(DB)
    ஍ਤ഑৴αʔό
    ܦ࿏୳ࡧαʔό
    ֤छσʔλ(Solr)
    ٯδΦݕࡧ

    View full-size slide

  18. EC2→Amazon ESҠߦͷܦҢ

    View full-size slide

  19. v1. ͱΓ͋͑ͣ࡞Γ·ͨ͠
    • όϥϯα͸CLBΛར༻ʢ౰࣌ࣾ಺ͰALB͋·Γ࢖ͬͯͳ͔ͬͨͷͰʣ
    • EC2ΛͱΓ͋͑ͣߏஙʢASGͳ͠ʣ
    • ֤EC2಺ͰͦΕͧΕͷIPΞυϨεΛอ࣋ʢElasticsearchͷઃఆʹ௚ॻ͖ʣ

    View full-size slide

  20. • ߏங͕͙͢ʹͰ͖ͨʢ׳Εͨߏ੒ʣ
    • Amazon ESʹͳ͍ElasticsearchόʔδϣϯΛ࢖͑ͨ
    Pros
    Cons
    • ෛՙ্ঢ࣌ʹAutoScaleͰ͖ͳ͍
    • Πϯελϯε͕མͪͨͱ͖ʹ෮چʹ͕͔͔࣌ؒΔ

    View full-size slide

  21. v2. গ͠վળ
    • ֤EC2ΠϯελϯεʹENIͰݻఆIPΛઃఆ
    • όϥϯαΛALBʹมߋʢIPΞυϨεͰϔϧενΣοΫ͢ΔͨΊʣ

    View full-size slide

  22. • Πϯελϯε͕མͪͯ΋ಉ͡IPΞυϨεΛ࢖͑Δ
    Pros
    Cons
    • ෛՙ্ঢ࣌ʹAutoScaleͰ͖ͳ͍
    • Πϯελϯε͕མͪͨͱ͖ʹ݁ہ෮چʹ͕͔͔࣌ؒΔ

    View full-size slide

  23. ϦϦʔε·Ͱ࣌ؒ΋ແ͘ɺ
    ಛʹ໰୊ͳ͘Քಇ͍ͯͨͨ͠ΊɺͱΓ͋͑ͣαʔϏεΠϯ

    View full-size slide

  24. ਺Χ݄ޙɾɾɾ

    View full-size slide

  25. ਺Χ݄ޙɾɾɾ
    ʮٯδΦ࢖͏αʔϏε͕૿͑·͢ʂʯ

    View full-size slide

  26. v2. ૿΍͢
    • ಉ͡΋ͷΛखಈͰىಈͤ͞ɺେྔϦΫΤετʹରԠɻɻɻ
    • ϦΫΤετ͕૝ఆҎԼͷ৔߹͸ɺखಈͰ੾Γ཭ͯ͠ఀࢭ

    View full-size slide

  27. v2. ૿΍͢
    • ར༻͞ΕΔυϝΠϯ͝ͱʹ͜ͷߏ੒Ͱߏங
    • අ༻/ӡ༻޻਺ͱ΋ʹ૿େ

    View full-size slide

  28. • masterϊʔυ͕ίϩίϩมΘΓɺಛఆͷΠϯελϯεͰ

    ෛՙ͕ߴ͘ͳΔ
    • ALBͷ5xxΤϥʔ཰͕ߴ͘ͳΔ
    • ϦΫΤετ͕૿͑ΔλΠϛϯάͷΈεέʔϧΞ΢τΛ͕Μ͹(ry
    EC2࣌୅ͷۤ࿑

    View full-size slide

  29. v3. ݱࡏͷߏ੒
    • Amazon ES΁Ҡߦ
    • ΞΫηε͸VPCΤϯυϙΠϯτܦ༝
    υϥΠϒαϙʔλʔ ΞϓϦέʔγϣϯαʔό APIαʔό
    ֤छσʔλ(DB)
    ஍ਤ഑৴αʔό
    ܦ࿏୳ࡧαʔό
    ֤छσʔλ(ES) ֤छσʔλ(Solr)

    View full-size slide

  30. • Πϯελϯεͷ؅ཧΛAWS͕΍ͬͯ͘ΕΔ
    • ઐ༻ϚελʔϊʔυΛઃఆ͢Δ͜ͱͰෛՙ͕ܰݮͰ͖Δ
    • ݁ՌɺΠϯελϯε୆਺͕࡟ݮͰ͖ͨ
    • EC2࣌ΑΓ΋ίετ͕໿3ׂݮ
    Pros
    Cons
    • Amazon ES࢖ͬͯ΋Φʔτεέʔϧ͸Ͱ͖ͳ͍
    • ElasticsearchόʔδϣϯΞοϓ࣌ʹ੾Γ໭͕ͮ͠͠Β͍
    • ઃఆมߋ࣌ʹBlue/GreenσϓϩΠͷΑ͏ͳڍಈʹͳΔ(͕͔͔࣌ؒΔ)

    View full-size slide

  31. Amazon ESͷ؂ࢹ

    View full-size slide

  32. • CloudWatchμογϡϘʔυ্Ͱ໨ࢹ
    • CloudWatchΞϥʔϜͰͷΤϥʔ௨஌
    Amazon ESͷ؂ࢹ

    View full-size slide

  33. • CloudWatchμογϡϘʔυ
    • ElasticsearchRequestsɿϦΫΤετ਺(Sum)
    • ClusterStatusɹɹɹɹ ɿΫϥελঢ়ଶ(Avg)
    • Nodesɹɹɹɹɹɹɹɹɿϊʔυ਺(Avg/Min)
    • 4xx/5xxErrorɹɹɹɹɹɿΤϥʔ਺(Sum)
    • Read/Search LatencyɹɿϨΠςϯγ(Avg/p99)
    • CPU UtilizationɹɹɹɹɿCPU࢖༻཰(Avg)
    • JVMMemoryPressureɹɿJavaώʔϓ%(Max)
    Amazon ESͷ؂ࢹ

    View full-size slide

  34. Amazon ESͷ؂ࢹ

    View full-size slide

  35. • CloudWatchΞϥʔϜ
    • 5xxError(Sum)
    • Search Latency(Avg)
    Amazon ESͷ؂ࢹ

    View full-size slide

  36. Amazon ESͷӡ༻

    View full-size slide

  37. AutoScale
    ͱ
    Upgrade&Downgrade

    View full-size slide

  38. • Amazon ESͱ͍͏ΑΓ΋Elasticsearchͱͯ͠Φʔτεέʔϧ
    ʹ͸ରԠ͍ͯ͠ͳ͍†
    • Amazon ESͰ͸σʔλϊʔυͷ਺Λ૿ݮͤ͞Δ͜ͱ͸Մೳ
    • σʔλϊʔυΛม͑ΔͱϨϓϦΧ਺Λมߋ͢Δඞཁ͕͋Δ
    Amazon ESͷӡ༻ ʙAutoScaleʙ
    † https://www.elastic.co/guide/en/cloud/current/ec-faq.html#faq-autoscale

    View full-size slide

  39. • Amazon ESͱ͍͏ΑΓ΋Elasticsearchͱͯ͠Φʔτεέʔϧ
    ʹ͸ରԠ͍ͯ͠ͳ͍†
    • Amazon ESͰ͸σʔλϊʔυͷ਺Λ૿ݮͤ͞Δ͜ͱ͸Մೳ
    • σʔλϊʔυΛม͑ΔͱϨϓϦΧ਺Λมߋ͢Δඞཁ͕͋Δ
    Amazon ESͷӡ༻ ʙAutoScaleʙ
    † https://www.elastic.co/guide/en/cloud/current/ec-faq.html#faq-autoscale
    LambdaΛ༻͍ͯΦʔτεέʔϧΛྗٕͰ࣮૷

    View full-size slide

  40. Amazon ESͷӡ༻ ʙAutoScaleʙ
    • SearchLatencyΛ؂ࢹ

    View full-size slide

  41. Amazon ESͷӡ༻ ʙAutoScaleʙ
    • SearchLatencyΛ؂ࢹ
    • SearchLatency͕ѱԽͨ͠ͷΛݕ஌ͨ͠Β
    LambdaΛൃՐ

    View full-size slide

  42. Amazon ESͷӡ༻ ʙAutoScaleʙ
    • SearchLatencyΛ؂ࢹ
    • SearchLatency͕ѱԽͨ͠ͷΛݕ஌ͨ͠Β
    LambdaΛൃՐ
    • Lambda͔ΒAmazon ESͷσʔλϊʔυΛ૿
    Ճͤ͞Δ

    View full-size slide

  43. Amazon ESͷӡ༻ ʙAutoScaleʙ
    • SearchLatencyΛ؂ࢹ
    • SearchLatency͕ѱԽͨ͠ͷΛݕ஌ͨ͠Β
    LambdaΛൃՐ
    • Lambda͔ΒAmazon ESͷσʔλϊʔυΛ૿
    Ճͤ͞Δ
    • ૿Ճ͕׬ྃޙɺϨϓϦΧ਺Λมߋ͢ΔϦΫΤ
    ετΛAmazon ESͷΤϯυϙΠϯτʹରͯ͠
    ౤͛Δ

    View full-size slide

  44. Amazon ESͷӡ༻ ʙAutoScaleʙ
    ɹ※ ࣄલʹσʔλϊʔυͱϨϓϦΧ਺ͷؔ܎ੑΛ
    ɹɹެࣜԽ͓ͯ͘͠ඞཁ͋Γ
    ɹ※ Lambdaͷ࣮ߦ࣌ؒʹ஫ҙ
    ɹ※ εέʔϧΠϯ΋ಉ͡

    View full-size slide

  45. • ΞοϓάϨʔυ
    • ແఀࢭͰElasticsearchͷΞοϓάϨʔυ͕Մೳ
    • όʔδϣϯΞοϓ͕໰୊ͳ͚Ε͹ܧଓతʹΞοϓάϨʔυ
    ͍ͯ͘͠΂͖
    Amazon ESͷӡ༻ ʙUpgrade&Downgradeʙ

    View full-size slide

  46. • μ΢ϯάϨʔυ
    • Elasticsearch6ܥˠ7ܥ΁ͷΞοϓάϨʔυ࣌ʹϨεϙϯε
    ͷ಺༰͕มΘΔมߋ͕ೖͬͨͷʹؾ͔ͮͣΞοϓάϨʔυ

    -> hits.total is now an object in the search response†
    • Amazon ES΁ͷϦΫΤετͰΤϥʔ͕ଟൃ…
    • μ΢ϯάϨʔυํ๏Λ໛ࡧ…
    Amazon ESͷӡ༻ ʙUpgrade&Downgradeʙ
    † https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#hits-total-now-object-search-response

    View full-size slide

  47. • ͙͢ʹͰ͖Δμ΢ϯάϨʔυํ๏͸ͳ͍
    • μ΢ϯάϨʔυํ๏
    • ৚݅ɿࣗಈεφοϓγϣοτΛऔ͍ͬͯΔ͜ͱ
    • ํ๏ɿAWSαϙʔτ΁࿈བྷ͠ɺ৽نυϝΠϯͰ
    ɹɹɹɹɹɹεφοϓγϣοτ͔Βͷ෮ݩΛґཔ
    • υϝΠϯͷมߋ͸ݫ͔ͬͨͨ͠ΊɺϨεϙϯεΛਖ਼͘͠ಡΊΔ
    Α͏ʹΞϓϦέʔγϣϯΛվम
    Amazon ESͷӡ༻ ʙUpgrade&Downgradeʙ

    View full-size slide

  48. ࠓޙͷ՝୊
    • Φʔτεέʔϧ৚݅ͷݟ௚͠
    • όʔδϣϯΞοϓ࣌ʹSearchLatency͕ѱԽ͢Δ͜ͱ͕͋
    ΔͷͰɺSearchLatencyҎ֎ͷ৚݅ΛࢦఆͰ͖ͳ͍͔ݕ౼
    • Elasticsearch on EC2ͷ๾໓
    • ·ͩҰ෦࢒͍ͬͯΔ؀ڥ͕͋ΔͷͰݱࡏҠߦத
    • 2݄தʹαʔϏεར༻தͷ΋ͷ͸׬શҠߦͰ͖ΔݟࠐΈ
    • OpenDistroࢼͯ͠ΈΔ

    View full-size slide

  49. ·ͱΊ
    • EC2ͰElasticsearchͷӡ༻͸ࢭΊ·͠ΐ͏
    • Amazon ESͰ؅ཧͰ͖ͳ͍෦෼͸Elasticsearchଆͷ໰୊΋͋
    ΔͷͰɺAWSͷϚωʔδυαʔϏεΛۦ࢖ͯ͠৐Γ੾Γ·
    ͠ΐ͏
    • όʔδϣϯΞοϓʹ͸஫ҙ͠·͠ΐ͏
    • Amazon ESΑΓ΋Elasticsearchͷ༗ࣝऀΛࣾ಺ʹ࡞͍͖ͬͯ
    ·͠ΐ͏

    View full-size slide

  50. • VPCΤϯυϙΠϯτʹରͯ͠Route53ͰυϝΠϯΛ͚͍ͭͨ
    • ઃఆมߋ࣌(ϩάͷઃఆͱ͔)ʹϊʔυ͕Blue/Greenʹͤͣʹม
    ߋͰ͖ΔΑ͏ʹͯ͠ཉ͍͠ʢ଴͕ͪ࣌ؒ௕͍ʣ
    • t2Πϯελϯε΋ϦβʔϒυΠϯελϯεͷର৅ʹͯ͠ཉ͍͠
    Amazon ES΁ͷཁ๬

    View full-size slide

  51. UltraWarm for Amazon ES

    View full-size slide

  52. • ΞΫηεස౓ͷগͳ͍σʔλΛUltraWarmετϨʔδ΁Ҡಈ͞
    ͤElasticsearchࣗମͷσΟεΫαΠζΛܰݮ͢Δ
    ɹɹ※ΠϯελϯελΠϓͱσΟεΫαΠζ͸ґଘؔ܎
    • ޲͍ͯΔ(ͱࢥ͏)༻్
    • ๲େͳσΟεΫΛ࢖͏৔߹
    • ΠϯσοΫεʹର͢ΔΞΫηεʹภΓ͕͋Δ৔߹
    • ݕࡧ͡Όͳͯ͘ϩά෼ੳϝΠϯ
    UltraWarm for Amazon ES

    View full-size slide

  53. φϏλΠϜͷ༻్Ͱ͸ίετϝϦοτແ͍ͷͰ࢖͏༧ఆ͸͋Γ·ͤΜ
    UltraWarm for Amazon ES

    View full-size slide

  54. UltraWarm for Amazon ES
    • ઐ༻Ϛελʔϊʔυʹt2ܥ͕࢖͑ͳ͍
    • Ϋϥελ؅ཧΛͯ͠Δ͚ͩͳͷͰݱঢ়t2Ͱे෼
    • m5.largeʹεέʔϧΞοϓ͢Δͱʙ2ສԁ/݄ίετΞοϓ
    • σΟεΫαΠζ͕TBະຬͳͷͰίετΧοτ΄΅Ͱ͖ͳ͍

    View full-size slide

  55. ©NAVITIME JAPAN

    View full-size slide