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

日本初のキャッシュレス即売会を支えた決済アプリ pixiv PAYの技術

orekyuu
November 06, 2018

日本初のキャッシュレス即売会を支えた決済アプリ pixiv PAYの技術

orekyuu

November 06, 2018
Tweet

More Decks by orekyuu

Other Decks in Technology

Transcript

  1. ೔ຊॳͷΩϟογϡϨεଈചձΛ
    ࢧܾ͑ͨࡁΞϓϦ pixiv PAYͷٕज़
    ۚ઒༞ଠ࿠ / ޒेཛྷ๜໌

    View full-size slide

  2. pixiv PAYͱ͸

    View full-size slide

  3. ໨త
    ΫϦΤʔλʔ͕ಉਓࢽͳͲͷ૑࡞෺ΛചΔ

    ଈചձͰ࢖ΘΕΔ͜ͱΛ໨తͱͨ͠

    ΩϟογϡϨεܾࡁαʔϏε

    View full-size slide

  4. എܠ
    •ଈചձͰ͸ݱۚࢧ෷͍ʹΑΔ͞·͟·ͳෆศ͕͋͞Δ

    •େྔͷ͓௼Γͷ४උ

    •͓௼Γͷ൥ࡶ͔͞Β1000ԁͳͲΩϦྑֹ͍ۚʹͤ͟ΔΛಘͳ͍

    •ച্ۚͷ౪೉ϦεΫ

    •ւ֎ސ٬͸೔ຊԁݱۚΛ४උ͢Δඞཁ͕͋Δ

    •ੈͷதͷΩϟογϡϨεԽɺిࢠܾࡁͷීٴ

    •͔͠͠ઐ༻ͷػց͕ඞཁͳͲͷཧ༝Ͱಋೖॳظඅ༻͕ߴ͍

    View full-size slide

  5. pixiv PAYͰఏڙ͍ͨ͠αʔϏεʢఏڙࡁΈؚΉʣ
    •ଟ༷ͳܾࡁํ๏

    •ΧʔυܾࡁɺίϯϏχೖۚϙΠϯτܾࡁɺച্ۚར༻ߪೖ

    •ϨδػೳʢΧʔυܾࡁҎ֎ʹɺݱۚձܭ෼΋ܭࢉՄೳʣ

    •ചΓखͱങ͍खΛͭͳ͙ػೳ

    •ϑΥϩϫʔʹϝοηʔδΛૹΔػೳ

    •ܾࡁ࣌ʹϖΠοʂͬͯ஻Δػೳ

    •੠༏͞Μʹ஻ͬͯ΋Β͍͍ͨɻͦͯͦ͠ΕΛ࣮૷͍ͨ͠ɻ

    View full-size slide

  6. RubyͰ։ൃ͢Δ͜ͱΛܾΊͨʢRubyͷར఺ʣ
    •৽͍͠ܗͷܾࡁαʔϏεͱͯ͠ɺ৽ػೳ͸ͲΜͲΜ௥Ճ͍ͨ͠

    •ੈͷதʹ·ͩͳ͍΋ͷΛࢼߦࡨޡͰ࡞Γ্͍͛ͯ͘

    •Railsͷॊೈ͞ɺ։ൃޮ཰ͷྑ͞ͱϚον

    •Rails੡ͷαʔϏε͕ࣾ಺ʹଟ͋ͬͨ͘

    •RailsΤϯδχΞ͕ࣾ಺ʹطʹଟ͍ͨ͘

    View full-size slide

  7. RubyͰ։ൃ͢Δ͜ͱΛܾΊͨʢRubyͷ՝୊ͱݒ೦ʣ
    • ଈചձͰ͸ܾࡁॲཧ͸։࢝௚ޙͷ୹ظؒʹूத͢Δ

    • 300ళͷଈചձͰ͸ɺ։৔௚ޙʹಉܾ࣌ࡁ਺͕300ۙ͘ͳΔ

    • ಉ࣌ʹൃੜ͢Δଟ͘ͷܾࡁϦΫΤετΛॲཧ͢Δ͜ͱ͕Ͱ͖Δ͔

    • ຊൃද͸͜ͷ఺ʹతΛߜ͓ͬͯ࿩͠͠·͢

    View full-size slide

  8. pixiv PAY։ൃεέδϡʔϧ
    • 2017೥6݄ ։ൃελʔτ

    • 2017೥8݄ ϦϦʔε

    • RailsΤϯδχΞʢͱεϚϗΞϓϦΤϯδχΞʣ͕
    ࣾ಺ʹطʹଟ͍ͨ͘ͷͰμογϡͰ࡞Εͨ

    • ϦϦʔεޙɺRails͸΄΅2ਓͰ։ൃ

    View full-size slide

  9. pixiv PAY ͷػೳ (ࠓ೔ݱࡏ)
    •εϚϗʹೖΕͨpixiv PAYΞϓϦͰQRίʔυͰചങ

    •ΫϨΧ΍PayPalͰܾࡁʢαʔόଆͰॲཧʣ

    •ίϯϏχͰೖۚͨ͠ϙΠϯτͰങ͍෺Մೳ

    •ଈചձʹಛԽͯ͠εϜʔεʹചങͰ͖ΔϨδػೳ

    •ෳ਺ਓͰചΓࢠ͕Ͱ͖ΔΞγελϯτػೳ

    •ߪೖऀ΍ϑΥϩϫʔ΁ͷϝοηʔδૹ৴ɺ৽ண৘ใ͓஌Βͤ

    •Πϕϯτొ࿥ػೳͰࢀՃ͍ͯ͠ΔചΓखΛݕࡧՄೳ

    •৽ػೳΛͲΜͲΜ௥Ճ͍ͯ͠Δ

    View full-size slide

  10. ࣗݾ঺հ
    •ޒेཛྷ๜໌ / twitter: igaiga555

    •ϑϦʔϥϯε RailsΤϯδχΞ

    •RubyWorld Conference 2013, 2014೥ ߨԋ

    •ౡࠜݝRuby߹॓ɺRailsࣉࢠ԰ɺRails GirlsͳͲͰߨࢣ

    •ஶॻʮθϩ͔ΒΘ͔ΔRuby௒ೖ໳ʯ 11/22ൃച

    View full-size slide

  11. ࣗݾ঺հ
    •ۚ઒༞ଠ࿠ / twitter: orekyuu

    •ϐΫγϒגࣜձࣾ RailsΤϯδχΞ

    •Ruby Business Users Conference 2018೥ొஃ

    View full-size slide

  12. pixiv MARKET
    • 2018೥6݄ ೔ຊॳΩϟογϡϨεಉਓࢽଈചΠϕϯτ
    pixiv MARKETΛ։࠵

    • pixiv PAYΛମݧͯ͠΋Β͏؀ڥΛͭ͘Δ

    • WiFi΋ࣗ෼ͨͪͰઃܭͯ͠ఏڙ

    • ళฮ਺Λ໿300ʹઃఆ

    View full-size slide

  13. ՝୊
    •300ళฮಉܾ࣌ࡁ

    •։࢝௚ޙʹܾࡁ͕ूத͢Δͱ༧૝

    •໿300ܾࡁ͕ಉ࣌ʹ͘Δ͜ͱΛ૝ఆ

    View full-size slide

  14. pixiv PAY ͷγεςϜߏ੒
    •Ruby, Rails੡

    •ΞϓϦέʔγϣϯαʔό3୆

    •ͦΕͧΕunicorn workerϓϩηε਺50

    • ࣾ಺ܾࡁج൫αʔϏεΛ௨ͯ͡ෳ਺ͷ֎෦ܾࡁ୅ߦαʔϏεΛར༻

    • ΫϨδοτΧʔυ, PayPal, ίϯϏχࣄલೖۚϙΠϯτ

    View full-size slide

  15. ରԠࡦ
    •ܾࡁॲཧͷߴ଎Խ

    •λΠϜΞ΢τରࡦ

    View full-size slide

  16. ܾࡁॲཧͷߴ଎Խ
    •ܾࡁॲཧ͸஗͍

    •֎෦αʔϏεAPIΛར༻͢ΔͨΊ

    •஗͍ͷͰܾࡁ଎౓ͷଌఆ͔Βߦͬͨ

    View full-size slide

  17. ܾࡁ଎౓ͷଌఆ
    •pixivi PAY͔Βࣾ಺ܾࡁج൫ͷMockԽܾͨ͠ࡁAPIΛୟ͍ͯɺେྔͷܾࡁϦ
    ΫΤετΛૹͬͨͱ͖ʹ஗͍ͱ͜Ζ͕ͳ͍͔Λௐ΂ͨ

    •ຊ൪ͷΞϓϦέʔγϣϯαʔόΛ1୆੾Γ཭ͯͦ͜͠ͰςετΛͨ͠

    •unicornϓϩηε਺30Ͱ25ചങ(50Ϣʔβʔ)ฒྻͰܾࡁΛ࣮ߦ͠ϦΫΤετ͔
    ΒϨεϙϯε·Ͱͷ࣌ؒΛଌఆ

    •ଌఆ݁Ռ

    •໿2ඵ(֎෦APIԠ౴଎౓ͱ΄΅ಉ౳)Ͱฦ͖͍ͬͯͯΔϦΫΤετ͕େ൒ͩ
    ͕ɺ5ඵ͔͔͍ۙͬͯ͘ΔϦΫΤετ͕͋ͬͨɻ

    •ܾࡁͷSlack௨஌Ͱ٧·͍ͬͯͨͷͰͦ͜ΛඇಉظԽͯ͠ߴ଎Խ

    View full-size slide

  18. ܾࡁॲཧ࣌ؒʢߴ଎Խޙʣ
    •֎෦APIͱͷ઀ଓ͕ඞཁͳΫϨδοτΧʔυɺPayPal͸֎෦APIͷॲཧ࣌ؒΑΓ
    ୹͘͸Ͱ͖ͳ͍

    •ඇಉظԽ΋ݕ౼͕͓ͨ͠٬༷ͷചങ଎౓͸্͛ΒͣݟૹΓ

    •֎෦APIͷॲཧ଎౓૬౰ͷʢ΄΅ʣݶք஋·Ͱߴ଎ԽͰ͖ͨ

    •pixiv PAYͷॲཧ଎౓͸ҎԼͷ௨Γ

    •ΫϨδοτΧʔυ: 1ʙ2ඵʢ֎෦API1ʙ2ඵʣ

    •PayPal: 3ʙ4ඵʢ֎෦API3ʙ4ඵʣ

    •ϙΠϯτ: 0.2ඵʢ֎෦APIෆཁʣ

    View full-size slide

  19. λΠϜΞ΢τ໰୊
    •க໋తͳ໰୊

    •ചΓखͱങ͍खͷؒͰ݁Ռ͕ҟͳͬͯදࣔ͞ΕΔ

    •ചΓखͱങ͍खʹ͸ചങࣦഊ͍ͯ͠ΔΑ͏ʹݟ͑Δ͕ɺ࣮ࡍ͸੒ޭ͠
    ͍ͯΔέʔε΋ى͜Γ͑Δ

    •໰୊ൃੜ͍ͯ͠ΔͱࢥΘΕΔϩάͰɺnginx͕εςʔλείʔυ499Λฦ
    ͍ͯ͠Δ͜ͱ͕͋Δ͜ͱ͕෼͔ͬͨ

    •εςʔλείʔυ499ͱ͸ɿRailsαʔό͕200OKΛฦ͕͢ɺΫϥΠΞ
    ϯτଆ͕ͦΕΛड͚औΒͣλΠϜΞ΢τͰ཭୤͢Δέʔε

    •λΠϜΞ΢τΛ׬શʹ๷͙ํ๏͸ͳ͍

    View full-size slide

  20. ໰୊͋Δέʔε
    ങ͍ख"QQ OHJOY

    0,

    0,

    0,

    &SSPS
    ܾࡁॲཧͰλΠϜΞ΢τ͢Δ৔߹
    ചΓख"QQ
    3BJMT
    0,
    ਖ਼ৗʹ
    ॲཧ׬ྃ
    &SSPS
    OHJOY͕
    ϨεϙϯεΛ
    ฦ͢ࡍɺ
    ΞϓϦ͕طʹ
    ଴ͬͯͳ͍࣌
    ܾࡁ
    ੒ޭ
    ܾࡁ
    ࣦഊ
    දࣔͷ૬ҧ

    View full-size slide

  21. λΠϜΞ΢τ໰୊ͷղܾํ๏
    •ܾࡁAPIΛҎԼͷ2ͭʹ෼཭

    •ܾࡁAPI(ঢ়ଶΛભҠͤ͞Δ)

    •݁Ռ֬ೝAPI(ঢ়ଶભҠͳ͠)

    View full-size slide

  22. ໰୊Λղܾͨ͠έʔε &SSPS࣌

    ങ͍ख"QQ OHJOY

    0,

    0,

    &SSPS
    ܾࡁॲཧͰλΠϜΞ΢τ͢Δ৔߹
    ചΓख"QQ
    3BJMT
    0,
    ਖ਼ৗʹ
    ॲཧ׬ྃ
    &SSPS
    ܾࡁ
    ੒ޭ
    ܾࡁ
    ੒ޭ
    ද͕ࣔҰக

    0,

    0,
    0,
    Τϥʔ࣌
    ࠶໰߹ͤ

    View full-size slide

  23. ໰୊Λղܾͨ͠έʔε ௨ৗ&SSPS࣌

    ങ͍ख"QQ OHJOY
    &SSPS
    ܾࡁॲཧͰλΠϜΞ΢τ͢Δ৔߹
    ചΓख"QQ
    3BJMT
    &SSPS
    ਖ਼ৗʹ
    ҟৗॲཧ
    &SSPS
    ܾࡁ
    ࣦഊ
    ܾࡁ
    ࣦഊ
    ද͕ࣔҰக
    &SSPS
    Τϥʔ࣌
    ࠶໰߹ͤ
    &SSPS
    &SSPS
    &SSPS
    &SSPS

    View full-size slide

  24. ໰୊͕ى͖ͳ͍͔Λ͔֬ΊΔςετ
    • ίʔυΛॻ͍ͯෛՙςετΛ࣮ࢪ

    • ߴෛՙ࣌ʹ΋໰୊͕ى͖ͳ͍͜ͱΛ֬ೝͰ͖ͨ

    • ࣾ಺Ͱ80ਓूΊ࣮ͯࡍͷΞϓϦͱαʔό؀ڥͰ
    Ұ੪ʹܾࡁ͢ΔςετΛ࣮ࢪ

    • Τϥʔ͕Ͱͳ͍͜ͱΛ֬ೝͰ͖ͨ

    View full-size slide

  25. ଈചձͷ݁Ռ
    •ଈചձ։࢝௚ޙʹҰؾʹΞΫη
    ε͕૿͍͑ͯΔ

    •ϐʔΫ࣌ͷಉܾ࣌ࡁ਺(ॲཧ࣌ؒ
    2ʙ4ඵ)͸1෼ؒʹ80ܾࡁ

    •ภΓ͕͋ΔͨΊɺඵؒ࠷େͷಉ
    ܾ࣌ࡁॲཧ਺͸6ॲཧ/ඵ

    View full-size slide

  26. ଈചձΞΫηεσʔλͷ݁࿦
    •ܾࡁAPIʢॲཧ࣌ؒ2ʙ4ඵʣ͸࠷େ80ॲཧ/෼

    •ඵؒ࠷େͷಉܾ࣌ࡁॲཧ਺͸6ॲཧ/ඵ

    •APαʔόʔ3୆߹ܭ150Workerʹಉܾ࣌ࡁॲཧ͕6ॲཧ

    •૝ఆΑΓ΋গͳ͘ɺ೉ͳ͘ॲཧΛࡹ͘͜ͱ͕Ͱ͖ͨ

    •ܾࡁ͕ूத͢Δ։࢝௚ޙ΋ॲཧͰ͖ͨ

    •ཧ࿦తʹ͸ɺαʔόΛ૿΍͢͜ͱͰ͞ΒʹॲཧͰ͖ΔϦΫΤετ਺
    Λ૿΍ͤΔ͜ͱ͕෼͔ͬͨ

    View full-size slide

  27. ໌Β͔ʹͳٕͬͨज़త՝୊
    •كʹॲཧʹ௕͕͔͔࣌ؒ͘ΔϦΫΤετ͕ൃੜ͍ͯ͠Δ͜ͱ͕ଈ
    ചձޙͷϩάνΣοΫͰ໌Β͔ʹͳͬͨ

    •nginxͷϩάΛ࣌ؒͷ͔͔ͬͨ΋ͷͰ߱ॱʹιʔτ͢Δͱɺฏৗ
    ࣌ͱൺ΂ͯ໌Β͔ʹ஗͍ʢ2ʙ4ඵʣ΋ͷ͕ݟ͔ͭͬͨɻ

    •Ұ෦ͷAPI͚ͩͰͳ͘શAPIͰكʹྼԽ͍ͯ͠Δݱ৅͕ݟΒΕͨɻ

    •࣍ͷϖʔδͰQRίʔυੜ੒APIͷϩάΛྫʹઆ໌͠·͢

    View full-size slide

  28. QRίʔυੜ੒APIͷϩά
    •ϩάΛ஗͍ॱͰιʔτ͢Δͱ2ඵҎ্͔͔͍ͬͯΔ΋ͷ͕ݟ͔ͭͬͨɻ

    •ීஈ͸0.5ඵҎԼ

    •QRίʔυੜ੒APIͷϩά(஗͍ॱ)

    View full-size slide

  29. Ծઆ: ϦΫΤετ͕ଟ͘ɺWorkerΛ࢖͍Ռͨͨ͠ʁ
    • WorkerΛ࢖͍Ռͨ͢έʔε͸ߟ͑ʹ͍͘

    • 150WorkerΛ࢖͍੾Δ΄Ͳͷ਺ͷϦΫΤετ
    ͸དྷ͍ͯͳ͔ͬͨ

    • ͞ΒʹɺϐʔΫλΠϜҎ֎ʹ΋ѱԽ͍ͯ͠Δ
    έʔε͕͋ͬͨ

    View full-size slide

  30. Ծઆ: unicornͷ࠶ىಈʹΑͬͯ஗͘ͳΔʁ
    •unicorn͕࠶ىಈͨ͠ͱ͖ʹ஗͘ͳΔέʔε͕ൃੜ͠͏Δ

    •ϩά͔Βunicorn worker killerʹΑͬͯԿ౓͔࠶ىಈ͍ͯ͠Δ͜ͱ͕൑໌

    •unicorn worker killer: ϦΫΤετճ਺ͰunicornΛ࠶ىಈ͢Δ࢓૊Έ

    •࠶ىಈ௚ޙͷϨεϙϯε͸໿4ඵ͔͔͍ͬͯͨ

    •mysqlͷίωΫγϣϯ࡞੒ʹ͕͔͔࣌ؒΔʁ

    •ϥΠϒϥϦಡΈࠐΈʹ͕͔͔࣌ؒΔʁ

    •Πϕϯτத͸unicornϓϩηεͷఆظ࠶ىಈͷ཈੍ͳͲͷํ๏Λݕ౼த

    View full-size slide

  31. Ծઆ: unicornͷ࠶ىಈʹΑͬͯ஗͘ͳΔʁ
    •unicorn࠶ىಈ࣌ʹ஗͘ͳΔέʔε͕ൃੜ͢Δ

    •ҰํͰ͜Ε͚ͩͰ͸શͯͷϨεϙϯελΠϜ
    ͷѱԽΛઆ໌Ͱ͖ͳ͍

    •ϩάʹ࢒͍ͬͯΔѱԽ͍ͯ͠ΔϨεϙϯεͷ
    ਺ʹରͯ͠࠶ىಈͷ਺͕߹Θͳ͍

    •ଞʹϨεϙϯε͕஗͘ͳΔݪҼ͕͋Δʁ

    View full-size slide

  32. ·ͱΊ
    •ଈചձͰͷܾࡁΛ؆୯ʹ͢ΔαʔϏεpixiv PAY ΛRuby,
    RailsΛ࢖ͬͯ։ൃͨ͠

    •೔ຊॳͷΩϟογϡϨεಉਓࢽଈചΠϕϯτΛ։࠵͠ɺ
    300ళฮͷܾࡁΛॲཧ͢Δ͜ͱ͕Ͱ͖ͨ

    •Ruby, RailsΛ࢖ͬͨγεςϜͰɺαʔόΛ૿΍͢͜ͱͰ
    ΑΓଟ͘ͷܾࡁϦΫΤετΛॲཧͰ͖Δݟ௨͠Λཱͯͨ

    View full-size slide

  33. એ఻
    • ଈചձΛ੝Γ্͍͖͍͛ͯͨΤϯδχΞΛืू͍ͯ͠·͢

    • ࢲୡͱҰॹʹRailsΛॻ͖·͠ΐ͏ʂ

    View full-size slide