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

Deep Dive into Momento

Deep Dive into Momento

yoshitaka KOITABASHI

September 15, 2023
Tweet

More Decks by yoshitaka KOITABASHI

Other Decks in Technology

Transcript

  1. Deep Dive into Momento

    View full-size slide

  2. © 2023, Momento, Inc.
    ࣗݾ঺հ
    Yoshitaka KOITABASHI (@yoshii0110)

    Momento - Community Advocate

    JAWS-UG ίϯςφࢧ෦ ίΞϝϯόʔ

    ిࢠ৘ใ௨৴ֶձ৘ใωοτϫʔΫݚڀձ

    ୈ5ճ৘ใωοτϫʔΫएखݚڀ঑ྭ৆ड৆

    View full-size slide

  3. @MomentoJP
    https://present.momentolabs.io/building-a-serverless-cache
    Momentoͷൿີ͕஌Γ͍ͨͰ͔͢ʁʁ
    ڭ͑·͠ΐ͏ʂ
    ※ ͳ͓ࠓճ͓࿩͢͠Δ಺༰͸ɺ

    طʹެ։͞Ε͍ͯΔ৘ใͷΈͱͳΓ·͢ɻ

    View full-size slide

  4. © 2023, Momento, Inc.
    Momento ͕໨ࢦ͢ੈք
    ΞϓϦέʔγϣϯΤϯδχΞʹͱͬͯ

    շదͳੈքΛ࡞͍͖ͬͯɺ൴ΒʹΑͬͯ

    ੜΈग़͞ΕͨαʔϏεΛΑΓૣ͘ɺΑΓηΩϡΞʹɺ

    ΑΓ҆ఆతʹૹΓग़͢࢓૊ΈΛఏڙ͢Δ
    @MomentoJP

    View full-size slide

  5. @MomentoJP
    MomentoͷΞϓϩʔν
    ༷ʑͳΫϥ΢υ্ͰαʔϏεΛ։ൃ͢Δ

    ։ൃऀΛॿ͚Δ࠷ߴͷαʔόϨεϓϥοτϑΥʔϜ
    ྺ࢙ͱͯ͠͸ɺ·ͣΩϟογϡ͔Β࢝·ΓࠓͰ͸

    ΠϕϯτυϦϒϯͳϝοηʔδϯάػೳΛఏڙ͍ͯ͠·͢ɻ
    Cache
    Topics (Pub/Sub)
    AI / ML

    View full-size slide

  6. @MomentoJP
    ͳͥΩϟογϡͳͷ͔ʁ
    Ωϟογϡ͸ɺ։ൃऀʹͱͬͯۤ௧Ͱ

    ͳΔ΂͘ͳΒ؅ཧͨ͘͠ͳ͘අ༻΋͔͔ͬͯ͠·͍·͢ɻ
    ͦͯ͠୭΋ͦͷϕετͳղܾࡦͱͳΔ

    αʔϏεΛ࡞͍ͬͯͳ͔ͬͨҝͰ͢ɻ

    View full-size slide

  7. ͦ΋ͦ΋ΩϟογϡͬͯͳΜͰ͔͢ʁ
    σʔλͷऔಘ͕ૣ͘ͳΔ
    Ұ࣌తͳσʔλετΞͱͯ͠

    ར༻Ͱ͖Δ
    γεςϜίϯϙʔωϯτ

    ʹର͢Δෛՙ͕ܰݮ͢Δ

    View full-size slide

  8. Ωϟογϡͷར༻ྫ

    View full-size slide

  9. @MomentoJP
    ͳͥ serverlessͳͷ͔ʁʁ
    Ϛʔέοτʹରͯ͠ૉૣ͘σϦόϦʔ͕Ͱ͖Δ
    ίϯγϡʔϚͷརศੑ͕޲্͢Δ

    (εέʔϦϯάͷ؍఺౳Ͱ)
    ΑΓηΩϡΞʹͳΔ
    අ༻͕҆͘ͳΔ

    View full-size slide

  10. serverlessͱ͸ͳΜͩ!?

    View full-size slide

  11. @MomentoJP
    αʔόʔϨε
    ͷఆٛ
    1ͭͷAPI ݺͼग़͠Ͱར༻Մೳ
    ϓϩϏδϣϯෆཁ


    ؅ཧෆཁ
    ࠷௿ྉۚͷແ͍


    ࢖ͬͨ෼͚ͩͷࢧ෷͍
    ܭըఀࢭ͕ແ͍
    Πϯελϯε͕ແ͍

    View full-size slide

  12. @MomentoJP
    αʔόϨεͷັྗ
    5ߦ૊ΈࠐΊ͹࢖͑Δखࠒ͞
    Create new cache
    Set a cache item
    Fetch the item value

    View full-size slide

  13. Momentoͷ

    ΞʔΩςΫνϟʹDeep Dive!!

    View full-size slide

  14. Cache Admin 

    - ίϯτϩʔϧϓϨʔϯ
    γεςϜϔϧεͷ؅ཧ

    ར༻ՄೳͳετϨʔδ༰ྔΛ؅ཧ
    ΞϓϦέʔγϣϯશମͷঢ়ଶΛҡ࣋

    View full-size slide

  15. MR2 - The Heart
    ϦΫΤετͷϧʔςΟϯάΛ୲౰
    ϊʔυؒͰσʔλΛෳ੡
    ϗοτΩʔͷ؅ཧ
    ϦΫΤετͷೝূͱσʔλͷݕূ
    ΞϓϦશମͷঢ়ଶΛϝϞϦ΁

    View full-size slide

  16. gRPCΛ࢖͏ཧ༝
    1: ௨৴ͷޮ཰ੑɺߴ଎ੑ

    2: Ϋϩεϥϯήʔδαϙʔτ
    https://docs.momentohq.com/ja/learn/how-it-works

    View full-size slide

  17. gRPCͱ͸ʁ
    ɾgRPCͱ͸ɺRPC(Remoto Procedure Call)Λ࣮ݱ͢ΔͨΊʹGoogle͕։ൃͨ͠ϓϩτίϧ
    ɾIDLͱͯ͠ɺProtocol BuffersΛ࢖ͬͯσʔλΛγϦΞϥΠζ͠ɺߴ଎௨৴Λ࣮ݱͰ͖Δ
    https://grpc.io/docs/what-is-grpc/introduction/

    View full-size slide

  18. Protocol Buffersͱ͸ʁ
    ɾProtocol Buffersͷ໾ׂͱͯ͠͸ɺIDLͰ͸͋Δ΋ͷͷߏ଄Խ͞ΕͨσʔλΛωοτϫʔΫܦ༝Ͱૹ৴
    ՄೳͳόΠτྻ΁γϦΞϥΠζ/σγϦΞϥΠζ͢ΔػೳΛ͍࣋ͬͯ·͢ɻ

    => ͳͷͰɺόΠφϦܗࣜͷσʔλΛऔΓѻ͑Δ͜ͱ͕ΑΓޮ཰ͷྑ͘௨৴Ͱ͖Δͱ͍͏༁Ͱ͢ɻ

    ɾ͜ͷ࣌ɺ͋Β͔͡ΊAPI࢓༷Λ.protoϑΝΠϧͱͯ͠ఆٛ͠ɺαʔόଆ/ΫϥΠΞϯτଆʹ

    ඞཁͳιʔείʔυͷ਽ܗΛੜ੒͠·͢ɻ
    ɾͳͷͰɺ͕͜͜ΫϩεϥϯήʔδରԠ͕Ͱ͖Δ఺Ͱɺݴޠʹґଘ͠ͳ͍IDLͰ

    ΠϯλʔϑΣʔεΛఆٛͰ͖ΔͷͰɺ༷ʑͳݴޠʹରԠͰ͖Δɻ
    https://grpc.io/docs/what-is-grpc/introduction/

    View full-size slide

  19. .protoϑΝΠϧͷఆٛͱίϯύΠϧ
    hoge.proto
    ίϯύΠϧ
    hoge.pb.go

    View full-size slide

  20. ͳͥΫϩεϥϯήʔδαϙʔτ͕خ͍͠ͷ͔
    Momento SDK΁ͷ
    ରԠͷҡ࣋ෛՙΛ

    ݮΒͨ͢Ί

    View full-size slide

  21. ALB / NLBʹ͍ͭͯ
    Elastic Load Balancer (ELB): AWS͕ఏڙ͢ΔϚωʔδυܕϩʔυόϥϯα
    ɾApplication Load Balancer (ALB)

    => εύΠΫ͕ൃੜͨ͠ࡍʹࣗಈεέʔϦϯά͕ؒʹ߹Θͳ͍Մೳੑ͕͋Δ
    => ALBͷج൫Ͱ͋ΔΠϯελϯε૿ڧ͕ཪͰؒʹ߹Θͳ͍ڪΕ͕͋Δ͜ͱ͔Βɺ্ݶ؇࿨ਃ੥΍ஆؾΛ͢Δඞཁ͕͋Δ

    ɾNetwork Load Balancer (NLB)
    => ஆػӡసෆཁͰεύΠΫʹ΋଱͑ΒΕΔ
    => AWS Hyperplaneͱ͍͏VPCΛͤ͞ΔػೳͷҰ෦ͱ࣮ͯ͠૷͞Ε͍ͯΔؔ܎Ͱɺ

    ߴ͍ύϑΥʔϚϯεͱՄ༻ੑΛఏڙͯ͘͠ΕΔ
    => ௕ظʹΘͨΓݻఆͷηογϣϯΛҡ࣋Ͱ͖Δ
    https://zenn.dev/momentobigfun/articles/94cd7e1f8735da

    View full-size slide

  22. Cache Nodes

    Ωϟογϡຊମ
    Ωϟογϡ͞ΕͨσʔλΛอ࣋͢Δ
    ύʔςΟγϣϯͰߏ੒͞Ε͍ͯΔ
    ΢ΥʔϜϓʔϧ /

    ΦʔόʔϓϩϏδϣχϯάεϖʔε
    εϫοϓՄೳͳετϨʔδΤϯδϯ

    View full-size slide

  23. ͜ΕΒͷίϯϙʔωϯτ͕ͲͷΑ͏ʹ࡞༻͢Δͷʁ

    View full-size slide

  24. Serverless Serviceͱͯ͠
    ͲͷΑ͏ʹ࡞༻͢Δͷ͔ʁ
    ୯ҰͷAPI ݺͼग़͠ͷ४උ
    ࢖༻ྔʹԠͨ͡Ձ֨ઃఆ
    ఏڙ͢Δ΋ͷ΋؅ཧ͢Δ΋ͷ΋ͳ͍

    View full-size slide

  25. ࠷৽৘ใ: VercelͱMomentoͱͷintegrationʂ
    https://vercel.com/integrations/momento

    View full-size slide

  26. © 2023, Momento, Inc.
    Momento ϢʔβίϛϡχςΟ

    ΋ΊΜͱձͷ͝঺հ
    Momento ΦϯϥΠϯίϛϡχςΟ(discord)
    @MomentoJP

    View full-size slide

  27. © 2023, Momento, Inc.
    ࠷৽৘ใΛ֬ೝ͢Δʹ͸ʁ

    View full-size slide