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

mrubyをプロダクションに
投入する / hosting-on-mruby

mrubyをプロダクションに
投入する / hosting-on-mruby

Rubyアソシエーション開発助成成果報告会
https://rubyassociation.doorkeeper.jp/events/74355

KONDO Uchio

July 07, 2018
Tweet

More Decks by KONDO Uchio

Other Decks in Technology

Transcript

  1. 8FCϗεςΟϯάج൫ར༻Ͱͷ࣮ূ࣮ݧɾ։ൃͷใࠂ
    ۙ౻Ӊஐ࿕(.01FQBCP *OD
    3VCZΞιγΤʔγϣϯ։ൃॿ੒੒Ռใࠂձ
    NSVCZΛϓϩμΫγϣϯʹ

    ౤ೖ͢Δ

    View full-size slide

  2. γχΞɾϓϦϯγύϧΤϯδχΞ
    ۙ౻ Ӊஐ࿕ / @udzura
    https://blog.udzura.jp/
    Uchio Kondo
    ٕज़෦ ٕज़ج൫νʔϜ

    View full-size slide

  3. $PNNVOJUZ
    Fukuoka.rb

    View full-size slide

  4. IUUQTNDMPMJQPQKQ

    View full-size slide

  5. େن໛ϗεςΟϯά
    ࣮ূ࣮ݧ

    View full-size slide

  6. ϗεςΟϯά࣮ূ࣮ݧ
    wίϯςφΛ༻͍ͨ8FCϗεςΟϯάͷγεςϜʹؔͯ͠ɺύϒϦοΫ
    Ϋϥ΢υ౳େ͖ͳϦιʔεΛ༻͍ͯ௨ৗͷ؀ڥͰ͸࣮ࢪ͠ʹ͍͘Α͏
    ͳ಺༰ͷ࣮ݧΛߦͬͨɻ
    wߴෛՙ࣌ͷڍಈɺඇৗʹूੵ཰͕ߴ·ͬͨ৔߹ͷڍಈͷ֬ೝͳͲ

    View full-size slide

  7. ͳͥ
    ϗεςΟϯάͰ

    View full-size slide

  8. ϗεςΟϯάݻ༗ͷٕज़త՝୊
    wҰൠతͳ8FCαʔϏεʹൺ΂ͯɺϓϥοτϑΥʔϜΛఏڙ͢Δϗε
    ςΟϯάαʔϏεͰ͸ҎԼͷΑ͏ͳ՝୊͕ݦஶʹͳΔ
    wγεςϜύϑΥʔϚϯεͷ໰୊
    wߴूੵੑͷ໰୊
    wηΩϡϦςΟͷ໰୊
    w͍ͣΕ΋ɺΞϓϦέʔγϣϯͷΈͳΒγεςϜྖҬͰͷ։ൃ͕ඞਢͱ
    ͳΔɻͦͷ௿໨ͷྖҬʹɺγεςϜϓϩάϥϛϯάʹڧ͍NSVCZ͸
    ϑΟοτ͢Δ

    View full-size slide

  9. ͓ޓ͍ͷվળ͸ؔ܎͠߹͏
    NSVCZΛར༻ͨ͠

    ϛυϧ΢ΣΞͷվળ


    NSVCZͷվળ
    ϗεςΟϯά
    ج൫ͷվળ

    View full-size slide

  10. NSVCZΛར༻ͨ͠
    ϛυϧ΢ΣΞͷվળ

    View full-size slide

  11. ୡ੒Ͱ͖ͨ੒Ռͷ͏ͪ

    ओͨΔ΋ͷΛ঺հ

    View full-size slide

  12. OHY@NSVCZ
    wߴੑೳͳ8FCαʔό࣮૷/HJOYͷڍಈΛɺNSVCZͰ੍ޚͰ͖ΔΑ͏ʹ
    ͢Δ֦ு
    wϩʔυόϥϯγϯά΍44-ূ໌ॻͷಈత؅ཧ͕؆ܿͳίʔυͰ࣮ݱ
    wࠓྲྀߦͷ4FSWJDF.FTI૚Ͱߦͳ͍ͬͯΔػೳͷઌۦ͚తଘࡏʁ

    View full-size slide

  13. OHY@NSVCZWͷϦϦʔε
    wࠓճͷॿ੒ʹΑΔ࣮ݧ಺༰Λड͚ɺઌ೔όʔδϣϯͷϦϦʔε
    wଟ͘ͷ௥ՃػೳΛ࣮૷

    View full-size slide

  14. ϦΫΤετϋϯυϥͷඇಉظԽ

    View full-size slide

  15. ϦΫΤετϋϯυϥͷඇಉظԽ
    wWҎલɺϫʔΧʔ͝ͱʹNSVCZͰͷॲཧ͸ϒϩοΫ͍ͯͨ͠ɻ
    wඇৗͳߴෛՙ࣌΍ɺNSVCZ಺Ͱ*0όΠϯυͳॲཧΛ͍ͯ͠Δ৔߹ʹ
    εϧʔϓοτ΍ॲཧϦΫΤετ਺ͷ໰୊͕ى͜Δ͜ͱ͕͋ͬͨɻ
    w͜ͷରԠͷҰ؀ͱͯ͠ɺNSVCZͷϋϯυϥॲཧΛ'JCFSΛϕʔεʹඇ
    ಉظԽ͢Δ͜ͱʹ੒ޭͨ͠
    w/HJOYࣗମͷΞʔΩςΫνϟʹ΋߹͍ͬͯΔ

    View full-size slide

  16. ࠓ·Ͱͷϋϯυϥͷڍಈ
    3FR 3FT
    NSVCZ

    View full-size slide

  17. Wʹ͓͚Δϋϯυϥͷڍಈ
    3FR 3FT
    NSVCZ
    *OJUNSC@TUBUF

    View full-size slide

  18. 'JCFSͷར༻
    'JCFSGPSFBDIIBOEMFS
    "XPSLFSQSPDFTT

    View full-size slide

  19. ϕϯνϚʔΫ
    IUUQTICNBUTVNPUPSKQFOUSZ

    View full-size slide

  20. େن໛ϗεςΟϯάʹ͓͚ΔӨڹ
    wେن໛ϗεςΟϯάͷҎԼͷՕॴͰOHY@NSVCZΛར༻
    w֎෦%#Λ༻͍ͨಈతͳϩʔυόϥϯγϯά
    wϦΫΤετܖػͰͷίϯςφىಈʢ'BTU$POUBJOFSʣ
    w͜ͷΑ͏ʹϋϯυϥ಺Ͱ֎෦"1*΁ͷΞΫηεɺ%#΁ͷΞΫηεͷΑ
    ͏ʹҰఆͷ*0଴͕ͪىͬͯ͜͠·͏ύλʔϯʹ͓͍ͯεϧʔϓοτͷ
    ໰୊͕͋ͬͨɻݱࡏ͸OHY@NSVCZWͷಋೖΛ׬ྃ

    View full-size slide

  21. ࠓޙͷ՝୊
    w౰વ·ͩར༻࣮੷͕গͳ͘ɺΤοδέʔεͰͷόά΋ଘࡏ͠͏ΔͷͰɺ
    ͦ͏ݴͬͨ΋ͷʹରॲ͍ͯ͘͠ඞཁ͕͋Δ
    w5$1TUSFBNͰͷϋϯυϥͳͲҰ෦͸·ͩ'JCFSԽ͞Ε͍ͯͳ͍ɻ௥
    ՃͰ։ൃ͍ͯ͘͠

    View full-size slide

  22. )BDPOJXB
    wNSVCZʹΑΓɺ༷ʑͳઃఆΛهड़Ͱ͖ΔίϯςφϥϯλΠϜ
    wҎԼͷػೳΛϓϩάϥϜͰ૊Έ߹ΘͤΔ͜ͱ͕Ͱ͖Δ
    w-JOVYͷϦιʔε෼཭ʢ-JOVY/BNFTQBDFͳͲʣɺϦιʔε੍ݶ
    ʢDHSPVQͳͲʣɺݖݶ੍ޚʢ-JOVY$BQBCJMJUZɺ4FDDPNQͳͲʣͷ
    ֤छίϯςφػೳ
    wίϯςφͷΠϕϯτʢىಈɺఀࢭɺྫ֎΄͔ʣ΍ɺىಈޙͷܦա࣌ؒ
    ʹ߹ΘͤͨϑοΫॲཧɺγάφϧϋϯυϥ

    View full-size slide

  23. 'BTU$POUBJOFS
    wίϯςφΛඞཁͳ࣌ʹॳΊͯىಈ͠ɺ·ͨఆظతͳίϯςφͷೖΕସ
    ͑Λ͢Δ͜ͱͰίϯςφͷ؅ཧίετͱϦιʔεޮ཰Λ޲্ͤ͞Δ

    ίϯςφ؅ཧͷΞʔΩςΫνϟ
    wݱࡏɺOHY@NSVCZ)BDPOJXBͰ࣮૷ͯ͠ɺαʔϏεͰͷӡ༻ʹ৐
    ͍ͤͯΔ

    View full-size slide

  24. 1JDUVSFPG'BTU$POUBJOFS
    Web

    Proxy
    Web

    Request

    Dispatcher
    FastContainer
    Runtime
    CMDB

    FastContainer
    Killed
    1. Check
    2. Boot
    3. Forward
    4. Terminate

    View full-size slide

  25. ىಈΦʔόʔϔουΛ௿ݮ͍ͨ͠
    wࠓճͷେن໛ϗεςΟϯάͰ͸ɺ'BTU$POUBJOFSΞʔΩςΫνϟΛ࠾
    ༻͠ɺίϯςφ؅ཧͱϦιʔεͷར༻ޮ཰ͷ࠷େԽΛਤ͍ͬͯΔ
    wʮඞཁͳ࣌ͷΈىಈ͢Δෆཁͳ࣌͸ίϯςφΛ࡞Βͳ͍ʯͱ͍͏Ξʔ
    ΩςΫνϟΛ࣮ݱ͢Δʹ͸සൟͳ࠶ىಈ͕ඞཁʹͳΓɺϢʔβମݧͱ
    ͍͏؍఺Ͱ͸ΞϓϦέʔγϣϯʹΑΓىಈ࣌ͷΦʔόʔϔουΛແࢹ
    Ͱ͖ͳ͍

    View full-size slide

  26. ઓུ

    wίϯςφͷىಈܧଓ࣌ؒΛ௕͘͢Δ

    ˠ૬ରతͳ଴ͪ࣌ؒͷׂ߹͕ݮΔͨΊɺϢʔβମݧ͸޲্͢Δ
    ىಈ

    ϦΫΤετՄೳ

    View full-size slide

  27. ίϯςφͷಉ࣌ىಈ਺
    w࣮ݧʹͯɺίϯςφͷಉ࣌ىಈ਺ʹؔ͢ΔݕূΛߦͬͨɻ
    w݁Ռͱͯ͠ɺγεςϜతͳ޻෉Ͱ࠷ऴతʹϗετͷϝϞϦ෼͚ͩͷى
    ಈ͸ͤ͞ΒΕΔ͜ͱ͕෼͔͕ͬͨɺ͜Ε͸ϋʔυ΢ΣΞతͳ্ݶͰ΋
    ͋Γɺಉ࣌ىಈ਺ΛͳΔ΂͘খ͘͞อͯΔͱ๬·͍͠
    w'BTU$POUBJOFSతʹ͸ɺىಈܧଓ࣌ؒΛͳΔ΂͘୹͘ɺਫ਼៛ʹϦιʔ
    είϯτϩʔϧ͕Ͱ͖ΔͱϕλʔͳγεςϜʹͳΔ

    View full-size slide

  28. ઓུ

    wىಈʹඞཁͳ࣌ؒࣗମΛ୹͘͢Δ
    wͦ΋ͦ΋ͷ଴͕ͪ࣌ؒҰఆҎ্খ͘͞ͳΕ͹ɺϨεϙϯελΠϜશମ
    ͷϘτϧωοΫΛΞϓϦέʔγϣϯʹҠ͢͜ͱ͕Ͱ͖Δ
    #PPUVQ
    "QQ
    -PHJD

    View full-size slide

  29. NSVCZͱ
    $3*6ͷ࿈ܞ

    View full-size slide

  30. $IFDLQPJOU3FTUPSF
    wϓϩηεͷ֤छଐੑ΍ϝϞϦঢ়ଶΛΠϝʔδʹμϯϓ͠ $IFDLQPJOU
    ɺ
    ͦΕΛݩʹϓϩηεΛߴ଎ʹ࠶ੜ͢Δ 3FTUPSF
    ٕज़
    wίϯςφ͸ϓϩηεͰ͋Δ™ͨΊɺίϯςφͷঢ়ଶμϯϓͱɺμϯϓ
    Πϝʔδ͔Βͷىಈʹ΋Ԡ༻Ͱ͖Δ
    w୅දతͳ࣮૷ͱͯ͠$3*6 $IFDLQJOU3FTUPSF*O6TFSTQBDF
    ͕஌
    ΒΕ͍ͯΔ

    View full-size slide

  31. $3*6
    w-JOVYʹ͓͚Δ$IFDLQPJOU3FTUPSFͷ࣮૷
    wQSPDͷ഑Լͷ৘ใΛऩू͠ɺϓϩηεͷϝϞϦͷঢ়ଶ΍֤छଐੑɺ
    ಛʹ/BNFTQBDF΍DHSPVQɺϑΝΠϧهड़ࢠ౳ͷঢ়ଶΛอଘ͢Δ
    wDSJVࣗମ͸αʔϏεԽ͢Δ͜ͱ΋ՄೳͰɺMJCDSJVͱ͍͏"1*ϥούʔ
    ͷ$࣮૷͕ఏڙ͞Ε͍ͯΔ
    w%PDLFSͷDIFDLQPJOUSFTUPSF࣮૷ʹ΋࢖ΘΕΔ

    View full-size slide

  32. ϗεςΟϯάͰͷ՝୊
    wίϯςφͷνΣοΫϙΠϯτΛ࡞੒͢ΔλΠϛϯά
    wϢʔβʔΞϓϦέʔγϣϯʹ͸ͲͷΑ͏ͳ΋ͷ͕৐Δ͔Θ͔Βͳ͍ͨ
    ΊɺՄೳͰ͋Ε͹ͳΔ΂͘อ͍࣋ͯ͠Δ৘ใ͕গͳ͍λΠϛϯάɺྫ
    ͑͹ϛυϧ΢ΣΞͷઃఆ͕ϝϞϦʹ৐ΓϙʔτΛϦεϯ͢Δ௚લɺͷ
    Α͏ͳ৔໘ͰνΣοΫϙΠϯτΛ࡞Γ͍ͨ
    w͜ͷࡍɺ೚ҙͷγεςϜίʔϧͳͲΛϑοΫʹνΣοΫϙΠϯτॲཧ
    Λ૸Β͍ͤͨ

    View full-size slide

  33. 4FDDPNQͷ׆༻

    View full-size slide

  34. 4FDDPNQʹΑΔγεςϜίʔϧϑοΫ
    wTFDDPNQͱ͸ɺಛఆͷϓϩάϥϜʹΑΔγεςϜίʔϧͷݺͼग़͠Λ
    ؂ࢹɺϑΟϧλϦϯά͢Δ-JOVYΧʔωϧͷػೳ
    wྫ͑͹ɺݺͼग़͠ͷېࢭڐՄɺݺͼग़͠ͷτϥοϓɺϩΪϯάͳͲ͕
    ՄೳͱͳΔ
    w੿࡞NSVCZTFDDPNQʹΑΓNSVCZͰ੍ޚͰ͖Δ

    View full-size slide

  35. 4FDDPNQˠ$3*6ͷ࿈ܞ
    wྫ͑͹ϛυϧ΢ΣΞ͕ىಈ͠ɺϙʔτΛϦεϯ͢ΔλΠϛϯά·Ͱʹ
    ͸༷ʑͳιέοτૢ࡞ͷγεςϜίʔϧ͕૸Δ
    wͦΕΒΛܖػͱͯ͠νΣοΫϙΠϯτΛ࡞੒͢Ε͹ɺىಈͷΦʔόʔ
    ϔουΛࣦͭͭ҆͘͠શʹϓϩηεΛ࠶ੜͰ͖Δ
    w)BDPOJXBͷΑ͏ͳ࣮૷Ͱ͋Ε͹ɺͦΕΒͷϥΠϒϥϦΛNSVCZͰϥο
    ϓ͠ɺ%4-ʹΑΓର৅γεςϜίʔϧͷࢦఆ͕Մೳ

    View full-size slide

  36. 4FDDPNQˠ$3*6ͷ࿈ܞ
    IBDPOJXBDIFDLQPJOU
    IBDPOJXBSFTUPSF
    $3*6JNBHFpMFT



    View full-size slide

  37. )BDPOJXBPO$3*6
    %&.0

    View full-size slide

  38. ࣮૷্ͷ՝୊
    wݱࡏɺʮ$3*6͕ϓϩηεΛఀࢭ͢Δॲཧʯͱʮ4FDDPNQ͕ϓϩηε
    Λఀࢭ͢Δॲཧʯ͕όοςΟϯάͯ͠͠·͏໰୊͕͋Δ
    wҰॠσλον͢Δ͜ͱͰճආ͍ͯ͠Δ͕ɺਖ਼֬ͳλΠϛϯάΛ੍ޚ͠
    ͍ͨ
    w$3*6ଆͰ͸ʢ͢Ͱʹࢭ·͍ͬͯΔͷͰʣఀࢭ͠ͳ͍Α͏ͳΦϓγϣ
    ϯΛύονͰ࣮૷͢Δɺ౳Λݕ౼

    View full-size slide

  39. ·ͱΊͱల๬

    View full-size slide

  40. ੒Ռͷ·ͱΊɾల๬
    wେن໛ϗεςΟϯά؀ڥͰNSVCZΛར༻͠ɺҎԼͷϛυϧ΢ΣΞվળ
    wOHY@NSVCZͷ'JCFSԽ
    w)BDPOJXBͱ$3*6ͷ࿈ܞʢ࣮૷վળதʣ
    wࠓޙ΋NSVCZར༻੒ՌΛΦʔϓϯʹ͍ͨ͠
    wใࠂ্ະୡ੒Ͱ͋ΔΦʔέετϨʔγϣϯ૚ͷ࣮૷ެ։΋ɺίϯς
    φͷվળͱͱ΋ʹਐΊ͍͖ͯͨ

    View full-size slide

  41. େن໛Ϋϥ΢υ࣮ݧ!/**
    wࠓճͷݚڀͰ͸ɺࠃཱ৘ใֶݚڀॴʢ/**ʣΫϥ΢υ࣮ূ࣮ݧʹΑΓ

    ఏڙ͞ΕͨΫϥ΢υ؀ڥΛར༻͍ͯ͠·ͨ͠
    IUUQTQFQBCPDPNOFXTQSFTT

    View full-size slide

  42. ͝ڠྗɾ͝ࢦಋ͍͍ͨͩͨօ༷
    wϖύϘͷಉ྅ͷํʑʢࢁԼ࿨඙͞Μɺాதྒհ͞Μʣ
    wϖύϘݚڀॴ٬һݚڀһɹDIJLVXB@*5͞Μ

    View full-size slide