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

Heroku を利用した Quipper の開発事例紹介

Heroku を利用した Quipper の開発事例紹介

Tech Compass Vol.6 “Love Heroku?” の発表資料です
http://techcompass.jp/study/06/

Kensuke Nagae

November 29, 2013
Tweet

More Decks by Kensuke Nagae

Other Decks in Programming

Transcript

  1. )FSPLVΛར༻ͨ͠
    2VJQQFSͷ։ൃࣄྫ঺հ
    5FDI$PNQBTTl-PWF)FSPLV z
    /PWFNCFS
    ,FOTVLF/BHBF!LZBOOZ

    View full-size slide

  2. w2VJQQFSͷ঺հ
    w2VJQQFSϓϥοτϑΥʔϜͰͷ
    )FSPLVͷ׆༻ࣄྫ঺հ
    w)FSPLVͷ࢖͍Ͳ͜ΖΛݟۃΊΔ
    w·ͱΊ
    ຊ೔ͷΞδΣϯμ

    View full-size slide

  3. !LZBOOZ͕͓ૹΓ͠·͢
    w௕Ӭ݈հ /BHBF,FOTVLF

    w೥݄d2VJQQFS
    w8FC%FWFMPQFS 3VCZ

    IUUQLZBOOZNF

    View full-size slide

  4. 2VJQQFS͸ɺϞόΠϧྖҬͷ
    ֶशϓϥοτϑΥʔϜΛఏڙ͍ͯ͠Δ
    ڭҭܥελʔτΞοϓاۀͰ͢
    IUUQXXXRVJQQFSDPNKBQBODBSFFST

    View full-size slide

  5. ຊࣾ͸ϩϯυϯͰ͕͢౦ژΦϑΟε΋͋Γ·͢
    χϡʔϤʔΫʹ΋ελοϑ͕ৗற͍ͯ͠·͢
    ৬छʹΑͬͯ͸ϩϯυϯɾΞδΞॾࠃ΁ͷग़ு΋

    View full-size slide

  6. IUUQHBLVNPTUVEZDPN
    தߴੜ޲ֶ͚शαʔϏεʮ(",6.0ʯ

    View full-size slide

  7. IUUQXXXRVJQQFSTDIPPMDPN
    ΞδΞ޲ֶ͚शαʔϏεʮ2VJQQFS4DIPPMʯ

    View full-size slide

  8. $SFBUJPO$FOUFS
    ίϯςϯπΛ࡞Δ
    2-JOL
    ֶशঢ়گΛ
    Ϟχλʔ͢Δ
    2-FBSO
    (",6.0
    ֶश͢Δ
    2VJQQFSϓϥοτϑΥʔϜ͸ࡾͭͷػೳΛ࣠ʹ
    ֤छαʔϏεΛల։͍ͯ͠·͢

    View full-size slide

  9. ಉ͡ΞϓϦέʔγϣϯΛ
    ผʑͷϒϥϯυͰల։͢Δ͜ͱ΋͋Γ·͢

    View full-size slide

  10. ΞϓϦέʔγϣϯͷಈ࡞֬ೝͷͨΊʹ
    ςετ༻ͷ؀ڥ΋ඞཁͰ͢Ͷ
    5FTUJOH 5FTUJOH

    View full-size slide

  11. ɾɾɾ͞ΒʹσϓϩΠલͷ࠷ऴνΣοΫ༻ʹ
    εςʔδϯά؀ڥ΋༻ҙ͠ͳ͍ͱ
    5FTUJOH 5FTUJOH
    4UBHJOH 4UBHJOH

    View full-size slide

  12. Ӧۀͷਓ
    ʮ΍͋ɺ͓٬͞ΜʹݟͤΔσϞ͸ແ͍ͷʁʯ
    5FTUJOH 5FTUJOH
    4UBHJOH 4UBHJOH
    %FNP
    %FNP

    View full-size slide

  13. 5FTUJOH 5FTUJOH
    4UBHJOH 4UBHJOH
    %FNP
    %FNP
    αʔόʔ͕͍ͭ͋ͬͯ͘΋଍Γͳ͍Αʂ
    ͍͍ͪͪηοτΞοϓͯ͠ΒΕͳ͍Αʂ
    ͜Μͳʹͨ͘͞Μ؅ཧͰ͖ͳ͍Αʂ

    View full-size slide

  14. )FSPLVΛ࢖͍·͠ΐ͏

    View full-size slide

  15. ͢΂ͯ)FSPLVͰӡ༻ͯ͠·͢

    View full-size slide

  16. wαʔόʔͷηοτΞοϓ࡞ۀ͕ෆཁ
    wΞϓϦέʔγϣϯͷઃఆ࡞ۀ͕؆୯
    wαʔόʔͷࢮ׆؂ࢹ͕ෆཁ
    wαʔόʔͷεέʔϧΞ΢τ͕؆୯
    w๛෋ͳΞυΦϯͰ֦ு΋؆୯
    )FSPLVͷڧΈ͸
    ʮӡ༻ͷෛ୲͕গͳ͍ʯ఺ʹ͋Γ·͢

    View full-size slide

  17. IFSPLVDSFBUF".&>
    ηοτΞοϓ͸ίϚϯυҰ͚ͭͩ
    Πϯετʔϧ࡞ۀ͸ෆཁͰ͢

    View full-size slide

  18. HJUQVTIIFSPLVNBTUFS
    ΞϓϦέʔγϣϯͷσϓϩΠʹ͸
    (JUΛ࢖͍·͢

    View full-size slide

  19. IFSPLVDPOpHTFU,&:7"-6&
    IFSPLVDPOpH
    ؀ڥม਺ͷઃఆɾ֬ೝ΋ίϚϯυͰ

    View full-size slide

  20. EJ⒎Va
    IFSPLVDPOpHBQQNZBQQQSPEVDUJPO
    a
    IFSPLVDPOpHBQQNZBQQTUBHJOH

    1SP5JQ؀ڥม਺ͷࠩ෼νΣοΫ

    View full-size slide

  21. IFSPLVQTTDBMFXFC
    εέʔϧΞ΢τ΋ίϚϯυҰ͚ͭͩʂ
    αʔόʔػثͷख഑ɾηοτΞοϓෆཁ
    ਺ඵͰϦιʔεΛ૿ڧͰ͖·͢

    View full-size slide

  22. IFSPLVGPSL&8/".&>
    ΞϓϦέʔγϣϯͷෳ੡΋Ͱ͖·͢
    ςετ༻ɾσϞ༻؀ڥ΋͙͢࡞Ε·͢

    View full-size slide

  23. IFSPLVDSFBUFBQQ
    HJUQVTIIFSPLVNBTUFS
    IFSPLVGPSLBQQEFNP
    IFSPLVDPOpHTFU%&.0BQQBQQEFNP
    σϞ༻ͷ؀ڥΛ࡞Δͱͨ͠Β͜Μͳײ͡

    View full-size slide

  24. ๛෋ͳΞυΦϯ
    /FX3FMJD ύϑΥʔϚϯεܭଌ

    View full-size slide

  25. ๛෋ͳΞυΦϯ
    4FOE(SJE ϝʔϧ഑৴

    View full-size slide

  26. ͦͷଞ͍͔ͭ͘࢖ͬͯ·͢
    w.FNDBDIJFS Ωϟογϡ

    w3FEJT5P(P ,FZ7BMVFετΞ

    w)FSPLV4DIFEVMFS DSPO

    w44-

    View full-size slide

  27. ͋͑ͯΞυΦϯΛ࢖Θͳ͍͜ͱ΋

    View full-size slide

  28. .POHP-BC .POHP%#ϗεςΟϯά

    wෳ਺ΞϓϦέʔγϣϯ͔Βڞ༗
    wݸผܖ໿ͷ΄͏͕ྉ͕͍ۚ҆
    wΞΫηεݖݶͷద੾ͳ੍ݶ
    wBEEPOTSFNPWFϛε๷ࢭ

    View full-size slide

  29. ͔͜͜Β͸۩ମతͳϢʔεέʔεΛ
    ঺հ͠·͢
    wϩάه࿥ϛυϧ΢ΣΞ
    w"1*αʔόʔͷϚΠάϨʔγϣϯ
    w#J[%FW͕1VMM3FRVFTUΛςετ

    View full-size slide

  30. Ϣʔεέʔε
    ϩάه࿥ϛυϧ΢ΣΞ

    View full-size slide

  31. Ϣʔεέʔε
    ϩάه࿥ϛυϧ΢ΣΞ
    wϦΫΤετɾϨεϙϯεΛ͢΂ͯه࿥
    wௐࠪ໨తͰ୹࣌ؒͷར༻Λ૝ఆ
    w3BDLϛυϧ΢ΣΞͱ࣮ͯ͠૷

    View full-size slide

  32. Ϣʔεέʔε
    ϩάه࿥ϛυϧ΢ΣΞ
    class LoggingMiddleware
    def initialize(app)
    @app = app
    end
    def call(env)
    ENV['ENABLE_LOGGING'] ? call_with_logging(env) : call_without_logging(env)
    end
    def call_with_logging(env)
    request = Rack::Request.new env
    status, headers, body = call_without_logging(env)
    Log.create(request: request, response: [status, headers, body])
    [status, headers, body]
    end
    def call_without_logging(env)
    @app.call env
    end
    end

    View full-size slide

  33. Ϣʔεέʔε
    ϩάه࿥ϛυϧ΢ΣΞ
    w؀ڥม਺Ͱ༗ޮɾແޮͷ੾Γସ͑
    wίʔυͷมߋɾσϓϩΠͱ΋ʹෆཁ
    wτϥϒϧ࣌ʹ͙͢࢖͑Δ

    View full-size slide

  34. Ϣʔεέʔε
    "1*αʔόʔͷϚΠάϨʔγϣϯ

    View full-size slide

  35. Ϣʔεέʔε
    "1*αʔόʔͷϚΠάϨʔγϣϯ
    w(SBQF 3BDL
    ͔Β3BJMTϕʔε΁
    wNBTUFSͱSBJMTϒϥϯνΛฒߦՔಇ
    w༷ࢠΛݟͳ͕ΒΏͬ͘Γ੾Γସ͑Δ

    View full-size slide

  36. αʔόʔߏ੒

    Database
    API

    View full-size slide

  37. αʔόʔߏ੒

    Database
    API API (Rails)

    View full-size slide

  38. αʔόʔߏ੒

    Database
    API API (Rails)

    View full-size slide

  39. "1*αʔόʔଆͷ࡞ۀ
    IFSPLVGPSLBQJSBJMTBQQBQJ
    IFSPLVEPNBJOTBEEBQJSBJMTRVJQQFSDPN
    HJUQVTIIFSPLVSBJMTNBTUFS

    View full-size slide

  40. ΞϓϦέʔγϣϯଆͷ࡞ۀ
    ʢ˞؀ڥม਺"1*@63-ͰΤϯυϙΠϯτΛࢦఆʣ
    IFSPLVDPOpHTFUa
    "1*@63-IUUQTBQJSBJMTRVJQQFSDPN

    View full-size slide

  41. ࠷খݶͷΦϖϨʔγϣϯͰҠߦ׬ྃ
    ʢ˞ΞϓϦέʔγϣϯͷ࣮૷ʹ΋ΑΓ·͕͢ɾɾɾʣ
    wμ΢ϯλΠϜແ͠ɺʮΏͬ͘ΓʯҠߦ
    w৽چαʔόʔΛฒߦՔಇ
    wαʔόʔΛʮ෦඼ʯͱͯ͠ѻ͏
    w%JTQPTBCMF$PNQPOFOUT

    View full-size slide

  42. wσϓϩΠɾ࠶ىಈɾઃఆมߋͷཤྺ
    wʮ୭͕ʯʮ͍ͭʯʮԿΛ͔ͨ͠ʯ
    w(JUͷίϛοτ͕ه࿥͞ΕΔ
    wෳ਺ਓͰͷӡ༻ʹ͸ඞਢ
    1SP5JQIFSPLVSFMFBTFT

    View full-size slide

  43. Ϣʔεέʔε
    #J[%FW͕1VMM3FRVFTUΛςετ
    ඇ։ൃऀ΋(JU)VC'MPXʹר͖ࠐΜͰ
    ΈΜͳϋοϐʔʹͳͬͨ࿩
    IUUQCMPHNBEPSPPSHNO

    View full-size slide

  44. ։ൃऀ͕1VMM3FRVFTU
    ʢςελʔ޲͚ͷνΣοΫϦετ෇͖ʣ

    View full-size slide

  45. +FOLJOT͕1VMM3FRVFTUϒϥϯνΛςετ
    (SFFOͩͬͨΒ)FSPLVʹσϓϩΠ

    View full-size slide

  46. ςελʔ͸σϓϩΠ͞Εͨ63-Λ։͍ͯ
    ϒϥ΢βͰಈ࡞νΣοΫ

    View full-size slide

  47. ίʔυϨϏϡʔςελʔͷಈ࡞νΣοΫ
    ྆ํ0,ͳΒଞͷ։ൃऀ͕Ϛʔδ

    View full-size slide

  48. %FNPOTUSBCMF1VMM3FRVFTUT
    wϚʔδ͕શһʹͱͬͯͷʮ׬ྃʯʹ
    wίϛϡχέʔγϣϯ͠΍͘͢ͳͬͨ
    wνʔϜશମͷεϐʔυײ͕͕͋ͬͨ
    wϦϦʔεɾσϓϩΠࣄނ͕ݮͬͨ
    IUUQTCMPHIFSPLVDPNBSDIJWFTIFSPLVGPSL

    View full-size slide

  49. ˞࣮ࡍͷίϚϯυ͸
    ΋ͬͱటष͍Ͱ͕͢ɾɾɾ
    IFSPLVGPSLBQJGFBUVSF(*5@#3"/$)BQQBQJ
    HJUQVTIa
    HJU!IFSPLVDPNBQJGFBUVSF(*5@#3"/$)HJUa
    (*5@#3"/$)NBTUFS

    View full-size slide

  50. ٯʹ)FSPLVͰΠϚΠνͳͱ͜Ζʁ
    w؀ڥม਺ʹґଘ͗͢͠ΔϦεΫ
    w)FSPLVʹ׳Ε͗ͯ͢ΨϥύΰεԽ͢ΔϦεΫ
    wݸਓͰ࢖͏ʹ͸ͪΐͬͱׂߴʢແྉ࿮আ͘ʣ
    wʢਖ਼௚ͦΜͳʹෆຬແ͍ʂʣ

    View full-size slide

  51. ؀ڥม਺ʹґଘ͗͢͠ΔϦεΫ
    wಈతʹܾ·Δ؀ڥม਺͸೺Ѳͮ͠Β͍ཁૉ
    wຊདྷ͸όʔδϣϯ؅ཧ͢΂͖ʢઃఆϑΝΠϧʣ
    wΞϓϦέʔγϣϯ͕؀ڥม਺ʹґଘ͗͢͠Δ
    wʮਖ਼͍͠஋ʯΛ஌Βͳ͍ͱಈ͔ͤͳ͍
    wυΩϡϝϯτͱίϛϡχέʔγϣϯͰΧόʔ

    View full-size slide

  52. ʢࣗ෼͕ʣΨϥύΰεԽ͢ΔϦεΫ
    w)FSPLVҎ֎ͷ؀ڥͰԿ΋Ͱ͖ͳ͘ͳΔ
    wྲྀߦͷ%FW0QTٕज़Λࢼ͢ػձ͕ແ͍
    wศར͗ͯ͢ΠϯϑϥͷτϨϯυʹૄ͘ͳΔ
    w)FSPLVϓϥοτϑΥʔϜʹғ͍ࠐ·ΕΔ
    w༨ՋΛར༻ͯ͠1BB4*BB4Λݚڀ͠·͠ΐ͏

    View full-size slide

  53. ݸਓͰ࢖͏ʹ͸ͪΐͬͱׂߴʢແྉ࿮আ͘ʣ
    wʮ͘͞Βͷ714ʯ͕҆͗͢Δ͚ͩʁ
    w౤ࢿͱࢥͬͯద౓ʹ՝ۚ͢Δͷ͕٢ʁ
    w)FSPLV͕Ṷ͔ͬͯ஋Լ͛͢ΔͱΈΜͳخ͍͠
    wզʑ։ൃऀ͕੝Γཱ͍͖ͯͯ·͠ΐ͏

    View full-size slide

  54. ·ͱΊ
    w2VJQQFSͷ։ൃࣄྫΛ঺հ͠·ͨ͠
    w)FSPLV͸༏ΕͨϓϥοτϑΥʔϜͰ͢
    w࢓ࣄʢϓϩμΫγϣϯ༻్ʣͰ࢖͑·͢
    w)FSPLVΤίγεςϜΛཧղ͢Δͱ͞Βʹศར

    View full-size slide