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

スタートアップのレガシーシステムをAws活用で改善している話

 スタートアップのレガシーシステムをAws活用で改善している話

第2回 関西スタートアップAWS勉強会
2016-04-21(木)18:30 - 21:30
https://kansaistartupaws.doorkeeper.jp/events/41786

Tomoyuki Sugita

April 21, 2016
Tweet

More Decks by Tomoyuki Sugita

Other Decks in Technology

Transcript

  1. ελʔτΞοϓͷϨΨγʔγ
    εςϜΛAWS׆༻Ͱվળͯ͠
    ͍Δ࿩
    ୈ2ճ ؔ੢ελʔτΞοϓAWSษڧձ

    2016-04-04 Thu @ άϩʔόϧϕϯνϟʔϋϏλοτେࡕ

    ΫοΫϏζגࣜձࣾ

    ਿా ஌ࢸ
    1

    View Slide

  2. ࣗݾ঺հ
    • ਿా ஌ࢸɹ@tomotomobile
    • ΫοΫϏζגࣜձࣾɹ։ൃ෦
    • Project Management, Growth hack, Recruiting
    • WordPress contributor, CoderDojo Umeda
    2
    < ࠙਌ձLT͠·ͨ͠

    View Slide

  3. ܦྺ঺հ
    • ֶੜىۀʢWeb੍࡞ʣ
    • ഇۀˍແ৬
    • Web੍࡞ձࣾۈ຿
    • ΫοΫϏζೖࣾ
    3

    View Slide

  4. AWSͷཧ૝తͳ࢖͍ํͰ͸ͳ͍͔΋͠Ε·ͤΜ
    ϨΨγʔγεςϜͱ෇͖߹͏্ͰAWS͕

    ͲͷΑ͏ʹ໾ཱͭͷ͔ࢀߟʹͳΕ͹޾͍Ͱ͢
    4

    View Slide

  5. ΞδΣϯμ
    • ΫοΫϏζͷ঺հ
    • ݱࡏͷ։ൃελΠϧ
    • ݱࡏʹࢸΔ·Ͱͷվળ
    • ࢒͍ͬͯΔ՝୊
    • ·ͱΊ
    5

    View Slide

  6. ӡ༻தͷWebαʔϏε
    ҿ৯ɾϑʔυؔ࿈ۀಛԽͷٻਓαΠτ

    ʮΫοΫϏζʯ
    ೶ۀʹ;ΕͯɾֶΜͰɾ࢓ࣄʹ͢Δ

    ʮϑΝʔϜϏζʯ
    ϑʔυؔ࿈ϋΠΫϥεٻਓʮϑʔδΣϯτʯ
    ҿ৯ਓࡐͷϓϩʹΑΔ"৯"ͷΩϡϨʔγϣϯαΠτ
    ʮΫοΫϏζ૯ݚʯ
    6

    View Slide

  7. ӡ༻தͷεϚʔτϑΥϯΞϓϦ
    7

    View Slide

  8. Foodion (ϑʔδϣϯ) https://foodion.net/
    04/21
    Released
    8

    View Slide

  9. ΞΫηε਺ɹ300%UP
    ʢhttp://cookbiz.jp ୯ମʣ

    View Slide

  10. 5ਓҎԼ 6ʙ30ਓ 31ʙ50ਓ 51ʙ99ਓ 100ਓҎ্
    10ԯԁҎ্ େձࣾ
    7ԯԁҎ্ தձࣾͷେ
    4ԯԁҎ্ தձࣾͷத
    4ઍສԁҎ্
    தձࣾͷখ
    4ઍສԁະຬ
    খձࣾ
    ձࣾن໛ʢখചɾαʔϏεʣ
    1೥લ͸͜ͷ΁Μ
    ※ඇ্৔גࣜͷձࣾن໛ͷ൑ఆʢ̨̢̗̘೔ڵূ݊ʣ

    http://www.smbcnikko.co.jp/corporate/mnr/buyback/buy03.htmlɹ
    10

    View Slide

  11. 5ਓҎԼ 6ʙ30ਓ 31ʙ50ਓ 51ʙ99ਓ 100ਓҎ্
    10ԯԁҎ্ େձࣾ
    7ԯԁҎ্ தձࣾͷେ
    4ԯԁҎ্ தձࣾͷத
    4ઍສԁҎ্
    தձࣾͷখ
    4ઍສԁະຬ
    খձࣾ
    ձࣾن໛ʢখചɾαʔϏεʣ
    ※ඇ্৔גࣜͷձࣾن໛ͷ൑ఆʢ̨̢̗̘೔ڵূ݊ʣ

    http://www.smbcnikko.co.jp/corporate/mnr/buyback/buy03.htmlɹ
    11

    View Slide

  12. ΞδΣϯμ
    • ΫοΫϏζͷ঺հ
    • ݱࡏͷ։ൃελΠϧ
    • ݱࡏʹࢸΔ·Ͱͷվળ
    • ࢒͍ͬͯΔ՝୊
    • ·ͱΊ
    12

    View Slide

  13. ΫοΫϏζͷ։ൃ؀ڥ͸͜Μͳײ͡
    • ݴޠɿPHP5.6 / DBɿMySQL5.5
    • PCɿMac / IDEɿPhpStorm
    • ϑϨʔϜϫʔΫɿΦϦδφϧ / Yii1 / Yii2
    • ςετϑϨʔϜϫʔΫɿCodeception
    • VMɿVagrant + Ansible
    • αʔόʔɿAWS EC2 + RDS
    13

    View Slide

  14. ͱ͋Δ৽نαʔϏεͩͱ͜Μͳײ͡
    • ݴޠɿPHP5.6 / DBɿMySQL5.7 + NoSQL
    • PCɿMac / IDEɿPhpStorm
    • ϑϨʔϜϫʔΫɿZendFramework2
    • αʔόʔɿAWS EC2 + S3 + RDS + DynamoDB + SES
    • ςετͱVM͸ݕ౼த
    14

    View Slide

  15. ։ൃϝϯόʔ
    15
    cook+biz farm+biz
    αʔόʔ
    ϑϩϯτ
    σβΠϯ
    ΞϓϦ
    σβΠϯ
    αʔόʔ ΅͘ ϩϘ
    14໊ʴ1ϩϘ
    https://cacoo.com/store/items/10023

    View Slide

  16. શϓϩδΣΫτΛεΫϥϜ։ൃͰ
    • Sprint : 2िؒ
    • ִि໦༵ʹRelease
    • Կ͔໰୊͕߹ͬͯ΋༵ۚ·ͰʹରԠͰ͖ΔΑ͏ʹ
    • લ೔ਫ༵͸Review Day
    • ͢΂ͯͷfeature / bugfix Λ։ൃϝϯόʔ͕ϨϏϡʔ
    16

    View Slide

  17. εΫϥϜ։ൃͱ͸
    εΫϥϜ (ιϑτ΢ΣΞ։ൃ) εΫϥϜʢӳ: Scrumʣ͸ɺ
    ιϑτ΢ΣΞ։ൃʹ͓͚Δ൓෮తͰ઴ਐతͳΞδϟΠϧ
    ιϑτ΢ΣΞ։ൃख๏ͷ1ͭͰ͋Δɻ ͜ͷํ๏࿦͸ʮॊ
    ೈ͔ͭશਓతͳϓϩμΫτ։ൃετϥςδʔͰ͋Γɺڞ
    ௨ͷΰʔϧʹ౸ୡ͢ΔͨΊɺ։ൃνʔϜ͕Ұମͱͳͬͯ
    ಇ͘͜ͱʯͱ͞ΕΔɻ
    2 weeks
    https://en.wikipedia.org/wiki/Scrum_(software_development)
    17

    View Slide

  18. 2छྨͷσΠϦʔεΫϥϜ
    • ։ൃνʔϜ
    • શϝϯόʔ͕ɺલ೔΍ͬͨ͜ͱ/ࠓ೔΍Δ͜ͱ/ࠔͬͯ
    Δ͜ͱΛڞ༗
    • ϓϩδΣΫτνʔϜ
    • ։ൃͰ໎ͬͯΔ͜ͱɺӡ༻Ͱ໎ͬͯΔ͜ͱΛڞ༗
    • PO΋ࢀՃͯ͠Δʂ
    18

    View Slide

  19. ϢχʔΫͳϧʔϧ Review Day
    Releaseલ೔ɺ͢΂ͯͷfeature / bugfix Λ։ൃϝϯόʔ͕
    ϨϏϡʔ͢Δɻͦͷ೔͸ɺ։ൃऀ͸։ൃͰ͖ͳ͍ɻ
    • ͲΜͳ͜ͱΛ͢Δͷ͔ʁ
    • ಈ࡞ϨϏϡʔ / ίʔυϨϏϡʔ / ϑϦʔσόοά
    • ࢓༷௨ΓͰ͖ͯΔ͚ͲվળͰ͖Δ఺ͷࢦఠ
    • ։ൃ؀ڥͷվળ
    19

    View Slide

  20. Gitͷӡ༻ϧʔϧ
    • feature
    • ػೳ௥Ճɺػೳมߋ
    • bugfix
    • όάͷमਖ਼
    • hotfix
    • ۓٸͰमਖ਼͠ͳ͚Ε͹ͳΒͳ͍όά
    • bizReq
    • ςΩετ΍ը૾मਖ਼ɾGrowthHackͳͲϏδωεཁٻ(Business Requirement)
    20

    View Slide

  21. ΞδΣϯμ
    • ΫοΫϏζͷ঺հ
    • ݱࡏͷ։ൃελΠϧ
    • ݱࡏʹࢸΔ·Ͱͷվળ
    • ࢒͍ͬͯΔ՝୊
    • ·ͱΊ
    21

    View Slide

  22. Program
    HTML
    Javascript
    Server
    Server
    Database
    Database
    Program
    HTML
    Mail
    https://pixabay.com/ja/%E3%82%B9%E3%83%91%E3%82%B2%E3%83%83%E3%83%86%E3%82%A3-napolitana-%E3%82%B9%E3%83%91%E3%82%B2%E3%83%83%E3%83%86%E3%82%A3-%E9%A3%9F%E5%93%81-%E7%9A%BF-83745/
    22

    View Slide

  23. ࢛ͷޒͷݴΘͣʹGitಋೖ͠·͠ΐ͏
    • ͍ͭɺͩΕ͕ɺͲ͜ʹɺͲΜͳมߋΛՃ͑ͨͷ͔

    ͢΂ͯͷϩά͕௥͑ΔΑ͏ʹͳΓ·͢
    • Git = Ӧۀ೔ใ
    23
    https://github.com/qw3rtman/git-fire

    View Slide

  24. FTP͔͠࢖͑ͳͯ͘΋Gitಋೖͨ͠ํ͕͍͍Α
    # αʔόʔʹফ͠๨ΕͨϑΝΠϧ͕͍ͬͺ͍͋ΔΑ(´ʀωʀʆ)
    # master ͱͷࠩ෼Ͱ࡟আ͞ΕͨϑΝΠϧͷΈநग़
    $ git diff --name-status master|grep "^D" > diffs.txt
    # Ξοϓϩʔυ͠๨ΕͨϑΝΠϧ͕෼͔Βͳ͍(´ʀωʀʆ)
    # master ͱͷࠩ෼ϑΝΠϧΛuploadsϑΥϧμʹநग़
    $ git diff --name-only master | git checkout-index
    --prefix=uploads/ --stdin
    24
    ͜Ε͚ͩͰ΋Ξοϓϩʔυָ͕ʹͳΓ·͢

    View Slide

  25. Ұ෦Ͱྑ͍͔ΒϑϨʔϜϫʔΫԽ
    • ٕज़తෛ࠴ͷτʔλϧฦࡁίετ͸૿͑Δ
    • ελʔτΞοϓʹ͸ۚ΋࣌ؒ΋଍Γͳ͍
    • શ෦Ұؾʹஔ͖׵͑Δͷ͸Ṷ͔͔ͬͯΒ΍Ε͹ྑ͍
    25

    View Slide

  26. WBS๒ͷ௚ܸΛड͚AWS΁ҠߦΛܾఆ
    • େखΦϯϓϨϛεܕαʔόΛར༻
    • WBS์ૹʹΑΓ12࣌ؒҎ্

    αʔόʔʹΞΫηεग़དྷͳ͍ঢ়گ
    • AWS΁ͷҠߦ͕࠷༏ઌࣄ߲ʹͳͬͨ
    26

    View Slide

  27. Ҡߦ४උͱͯ͠σϓϩΠεΫϦϓτ࡞Γ·ͨ͠
    • Git͔ΒAWSʹιʔείʔυΛPull+Buildͯ͠ެ։ྖҬʹrsync
    • Ξοϓϩʔυ͞Εͨը૾ɺDBΛrsyncͰసૹ
    • GitೖΕͱ͍ͯΑ͔ͬͨʂʂ
    27
    Code
    Image & DB
    Code

    View Slide

  28. ҠߦͷϦϋʔαϧ͸ೖ೦ʹɺςετ؀ڥฤ
    • ༧ΊDNS͸R53ʹมߋ
    • Amazon LinuxͰίʔυ͕ಈ͔͘ςετ
    • ಈ͔ͳ͍෦෼͸मਖ਼͓ͯ͘͠
    28

    View Slide

  29. ҠߦͷϦϋʔαϧ͸ೖ೦ʹɺຊ൪؀ڥฤ
    • (౰࣌ͷ)ཧ૝తͳߏ੒Λ࡞Δ
    • σϓϩΠεΫϦϓτͰσϓϩΠ

    ໰୊͕͋Ε͹मਖ਼
    • RDSͷTimezone͕UTCͩͱؾ͖ͮ

    ΞϓϦέʔγϣϯΛमਖ਼ (ݱࡏ͸Timezoneબ୒Ͱ͖·͢)
    • ຊ൪ҠߦͷखॱΛॻ͖ग़͠ɺҠߦ౰೔͸ॱ൪ʹ࣮ߦ͢
    Δ͚ͩͷঢ়ଶʹ͓ͯ͘͠
    29

    View Slide

  30. ͍͟ɺ੾Γସ͑
    • EC2ͰϝϯςφϯεαΠτΛ্ཱͪ͛Δ
    • Route53Ͱຊ൪υϝΠϯΛϝϯςαΠτʹ޲͚Δ
    • ҠߦલαʔόͷcronΛࢭΊΔ
    • Ҡߦલαʔόͷϩά͕ಈ͔ͳ͘ͳΔͷΛ଴ͭ
    • ը૾ͷࠩ෼ΛrsyncͰऔಘɺDBΛΠϯϙʔτ
    • ಈ࡞ݕূͯ͠ɺ໷ؒόονΛ࣮ߦɺcronઃఆ
    • Route53Ͱຊ൪υϝΠϯΛ৽αʔόʹ޲͚Δ
    30

    View Slide

  31. ͍͟ɺ੾Γସ͑
    • EC2ͰϝϯςφϯεαΠτΛ্ཱͪ͛Δ
    • Route53Ͱຊ൪υϝΠϯΛϝϯςαΠτʹ޲͚Δ
    • ҠߦલαʔόͷcronΛࢭΊΔ
    • Ҡߦલαʔόͷϩά͕ಈ͔ͳ͘ͳΔͷΛ଴ͭ
    • ը૾ͷࠩ෼ΛrsyncͰऔಘɺDBΛΠϯϙʔτ
    • ಈ࡞ݕূͯ͠ɺ໷ؒόονΛ࣮ߦɺcronઃఆ
    • Route53Ͱຊ൪υϝΠϯΛ৽αʔόʹ޲͚Δ
    31

    View Slide

  32. ͍͟ɺ੾Γସ͑
    • EC2ͰϝϯςφϯεαΠτΛ্ཱͪ͛Δ
    • Route53Ͱຊ൪υϝΠϯΛϝϯςαΠτʹ޲͚Δ
    • ҠߦલαʔόͷcronΛࢭΊΔ
    • Ҡߦલαʔόͷϩά͕ಈ͔ͳ͘ͳΔͷΛ଴ͭ
    • ը૾ͷࠩ෼ΛrsyncͰऔಘɺDBΛΠϯϙʔτ
    • ಈ࡞ݕূͯ͠ɺ໷ؒόονΛ࣮ߦɺcronઃఆ
    • Route53Ͱຊ൪υϝΠϯΛ৽αʔόʹ޲͚Δ
    32

    View Slide

  33. AWS΁ͷҠߦ΍ͬͯΈͯؾ͍ͮͨ͜ͱ
    • σϓϩΠεΫϦϓτศར
    • Ϧϋʔαϧେࣄ
    • 2ճҐϦϋʔαϧͰ͖ΔͱෆଌͷࣄଶΛආ͚ΒΕΔ
    • ҎޙɺϦϦʔεϦϋʔαϧ͕ఆணͨ͠
    • Route53͛͢ʔ
    33

    View Slide

  34. ͠͹Β͘ฏԺͳ೔ʑ͕ଓ͖
    ։ൃϝϯόʔ૿һɺ։ൃྗ্͕͕Δ
    34

    View Slide

  35. ϦϦʔε͢Δͨͼʹόά͕ग़Δ҉ࠇ࣌୅
    • ։ൃΛੵۃతʹ͢ΔΑ͏ʹͳΓϦϦʔεճ਺͕૿͑ͨ
    • ϦϦʔεͯ͠͸όάमਖ਼ʹ௥ΘΕɺεέδϡʔϧ͕࣍ʑ
    ʹഁ୼
    • εέδϡʔϧ͕ϠόΠͷͰɺߋʹ඼࣭͕ѱԽ
    ׬શʹෛͷεύΠϥϧʂʂ
    35

    View Slide

  36. όά࡟ݮͱ඼࣭޲্ͷͨΊʹ΍ͬͨ͜ͱ
    • ΧϯόϯํࣜˠεΫϥϜ։ൃ
    • UIςετͷಋೖ
    36

    View Slide

  37. Χϯόϯํ͔ࣜΒεΫϥϜ։ൃ΁
    • ͦΕ·Ͱɺ׬੒ͨ͠ίʔυ͔Βॱ࣍σϓϩΠ͍ͯͨ͠
    ͷΛ1िؒεϓϦϯτͷεΫϥϜ։ൃʹมߋ
    • Review DayΛಋೖ

    (Releaseલ೔ɺ͢΂ͯͷfeature / bugfix Λ։ൃϝϯόʔ͕ϨϏϡʔ͢Δɻ)
    • ݁Ռɺ։ൃʹϦζϜ͕ੜ·Εɺશһ͕඼࣭ʹҙࣝΛ޲
    ͚Δ͜ͱ͕ग़དྷɺεέδϡʔϧ่͕Εʹ͘͘ͳͬͨ
    37

    View Slide

  38. εΫϥϜ։ൃ΍ͬͯΈͯؾ͍ͮͨAWSརศੑ
    • εςʔδϯά؀ڥ͕
    ඞཁͳͷ͸ਫ༵͚ͩ
    • Ր༵༦ํɺEC2+RDSΛى
    ಈͯ͠ɺσϓϩΠ
    • ਫ༵໷ɺEC2+RDSΛఀࢭ
    • εςʔδϯά؀ڥͷ
    ίετΛ1/7ʹઅ໿
    38

    View Slide

  39. Codeception+SeleniumͰUIςετ
    • ϨΨγʔγεςϜ͸ςετίʔυ͕
    ॻ͚ͳ͍
    • ϒϥ΢βΛૢ࡞ͯ͠ɺಈ࡞͕ਖ਼͍͠
    ͔Ͳ͏͔ͷςετΛࣗಈԽ
    • ػೳมߋޙͷσάϨνΣοΫ͕༰қ
    ʹͳΓ·ͨ͠
    39
    http://www.slideshare.net/
    FlorentBatard/php-kansai-phpkansai
    ৄ͘͠͸ͪ͜Β

    View Slide

  40. Codeception+SeleniumͰUIςετ
    • jQueryͷهड़ͷΑ͏ͳΘ͔Γ΍͢͞
    40

    View Slide

  41. View Slide

  42. UIςετ͸ֻ͕͔࣌ؒΔͷͰࣗಈͰ
    • ςεταʔόʔʹPushͯ͠

    ຖ൩ࣗಈͰςετ
    • RDSͷεφοϓγϣοτ͔Β

    σʔλϕʔεΛຖ೔Ϧηοτ
    42
    ϩϘ

    View Slide

  43. εΫϥϜͱAWS͸૬ੑ͕ྑ͍Ͷ
    • ඞཁͳͱ͖ʹඞཁͳ͚ͩαʔόʔΛ༻ҙͰ͖Δ
    • εΫϥϜͩͱ͍ͭඞཁͳͷ͔͕໌֬
    • ΄ͱΜͲͷαʔόϦιʔεΛAPIͰૢ࡞Ͱ͖Δ
    • αʔόઃఆʹࣦഊͯ͠΋εφοϓγϣοτ͔Β͙͢෮
    ݩͰ͖Δ
    43

    View Slide

  44. ΞδΣϯμ
    • ΫοΫϏζͷ঺հ
    • ݱࡏͷ։ൃελΠϧ
    • ݱࡏʹࢸΔ·Ͱͷվળ
    • ࢒͍ͬͯΔ՝୊
    • ·ͱΊ
    44

    View Slide

  45. AWS API͕ඇಉظͳͷͰͪΐͬͱ͚ͩࠔͬͯΔ
    • εςʔδϯά؀ڥͷىಈΛεέδϡʔϧ࣮ߦ
    • ΠϯελϯεىಈޙͷϑΟʔυόοΫ͕དྷͳ͍ͷͰɺͦ
    ΖͦΖ͔ͳʙͱ͍͏λΠϛϯάͰ໰͍߹ΘͤͯΔ
    • Lambda࢖͑͹ྑ͍ͷ͔ͳʁ
    45
    ϩϘ
    Πϯελϯεىಈͯ͠
    ىಈͰ͖ͨʁ
    ϩϘ

    View Slide

  46. εέʔϧͷ՝୊
    46
    S3͕ډͳ͍

    View Slide

  47. ը૾Ξοϓϩʔυઐ༻ͷϥΠϒϥϦ࡞Γ·͠ΐ͏
    • ΞϓϦέʔγϣϯͷ͋ͪͪ͜ʹ͜Μͳίʔυ͕͋Δͱ
    Ϡόա͗Δɻ
    • Ξοϓϩʔυ΍࡟আ͸ҰՕॴͰ؅ཧ͠·͠ΐ͏ɻ
    47
    move_uploaded_file(
    $_FILES['file']['tmp_name'],
    './image.jpg');

    View Slide

  48. DBͷI/O͕ϠόΠ
    • EC2΋RDS΋CPUͱϝϞϦ͸༨༟ͳͷʹɺI/OͰ٧·ͬ
    ͯ͠·͏
    • Aurora࢖ͬͯΈ͍ͨͶɺ·ͣ͸MySQL5.6ʹ্͛ͳ͍ͱ
    • ͍ͬͯ͏͔ΞϓϦέʔγϣϯͷίʔυͰվળͰ͖Δ͔΋
    48
    https://ja.wikipedia.org/wiki/%E5%A4%A7%E5%90%8D%E8%A1%8C%E5%88%97

    View Slide

  49. ࢒ͬͯΔ՝୊Λղܾͯ͘͠ΕΔΤϯδχΞืूத

    http://recruit.cookbiz.co.jp/

    View Slide

  50. WantedlyͰ΋ืूͯ͠·͢
    50

    View Slide

  51. ΞδΣϯμ
    • ΫοΫϏζͷ঺հ
    • ݱࡏͷ։ൃελΠϧ
    • ݱࡏʹࢸΔ·Ͱͷվળ
    • ࢒͍ͬͯΔ՝୊
    • ·ͱΊ
    51

    View Slide

  52. ϨΨγʔγεςϜΛAWS׆༻Ͱվળ͍ͯ͠Δ࿩
    • αʔό͸؆୯ʹཱͯΒΕΔͷͰɺϦϋʔαϧΛೖ೦͠
    ·͠ΐ͏
    • εΫϥϜ΍ࣗಈԽΛಋೖ͢ΔͳΒɺAPIͰαʔόΛૢ࡞
    Ͱ͖ΔAWS͕ͽͬͨΓ
    • ࠓ೔ͷΑ͏ͳษڧձͰৄ͍͠ਓʹ૬ஊ͠·͠ΐ͏
    • ؔ੢ʹ͸ਗ਼ਫ͞Μ͕͍·͢ɻ૬ஊ͠·͠ΐ͏
    52

    View Slide

  53. Enjoy development!!
    ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠
    53

    View Slide