Developer Productivity in Cookpad

Developer Productivity in Cookpad

クックパッドはなぜ開発しやすいのか

At AWS Summit Tokyo 2015 Developer Conference
2015/06/03

6f8e101c016fa7ebbe58e693dbd86b7d?s=128

Issei Naruta

June 03, 2015
Tweet

Transcript

  1. ΫοΫύου͸ͳͥ ։ൃ͠΍͍͢ͷ͔ ΫοΫύουגࣜձࣾ੒ాҰੜ "844VNNJU5PLZP

  2. ੒ాҰੜ ͳΔͨ ͍͍ͬͤ !NJSBLVJ ΫοΫύουגࣜձࣾ ΠϯϑϥετϥΫνϟʔ෦௕

  3. ΫοΫύουʹ͍ͭͯ

  4. .6#NP .14VTFST .DPPLJOHSFDJQFT ˞೥݄ݱࡏ !" # !

  5. 'VMM"84 2011೥3݄ ౦ژϦʔδϣϯΦʔϓϯ 2011೥8݄ DC͔ΒAWS΁Ҡߦ ✈

  6.  &$JOTUBODFT BUQFBL  SFRTFD BUQFBL $

  7. 0QT  %FWFMPQFST  %FQMPZTEBZ ⚒ #

  8. IUUQTTQFBLFSEFDLDPNB@NBUTVEBUIFSFDJQFGPSUIFXPSMETMBSHFTUSBJMTNPOPMJUI ΫοΫύου͸ੈքҰڊେͳ ϞϊϦγοΫ3BJMTΞϓϦέʔγϣϯʢ͔΋͠Ε·ͤΜʣ

  9. None
  10. ʮ։ൃ͠΍͍͢ʯͱ͸Կ͔

  11. % ʮ։ൃ͠ʹ͍͘ʯঢ়ଶͷྫ ٕज़తͳ໰୊ʹΑͬͯΠϊϕʔγϣϯ્͕֐͞Ε͍ͯΔঢ়ଶ େྔͷϨΨγʔίʔυɺٕज़తෛ࠴ ςετ͸͋Δ͚Ͳৗʹ͍͔ͭ͘ Fail ͍ͯͯ͠ɺ
 ์ஔ͞Ε͍ͯΔ σϓϩΠ͕ଐਓతͰɺ͕͔͔࣌ؒΓ͗ͨ͢Γɺ
 ͨ·ʹࣦഊͨ͠Γ͢Δ

  12. ։ൃ͠ʹͯ͘͘Կ͕ѱ͍ʁ ݱ৔ָ͕Λ͍ͨ͠ ૉૣ͘Ձ஋Λఏڙ͍ͨ͠

  13. ⚒ ։ൃ σϓϩΠ ςετ

  14. ։ൃ ⚒

  15. None
  16. None
  17. αʔϏε։ൃͱ͸Կͳͷ͔ ࡞͍ͬͯΔͷ͸ʮػೳʯͰ͸ͳ͘ʮαʔϏεʯʮϢʔβମݧʯ μϛʔσʔλͰ͸ͳ͘ຊ൪ͷσʔλΛ࢖ͬͯ։ൃ͢Δ΂͖ &

  18. ຊ൪ͱಉظͨ͠%#Ͱ։ൃ͢ΔϝϦοτ • Ϣʔβʔͱಉ౳ͷମݧ • ༧ظͤ͵σʔλʹΑΔόάʹؾ͖ͮ΍͍͢ • ॏ͍ΫΤϦʹؾ͖ͮ΍͍͢

  19. '# ຊ൪%# ։ൃ%# ։ൃऀ .Z42- .Z42- NZTRMEVNQ ( # ։ൃऀͷ୭͔͕ؾ͕޲͍ͨ࣌ʹ

    ຊ൪μϯϓσʔλ͔Β։ൃ DB Λߋ৽ ʢ൒೥ʹ1౓͘Β͍ʣ d
  20. खಈߋ৽ํࣜͷ໰୊఺ ݱߦͷσʔλͷΈͰൃੜ͢ΔΑ͏ͳΤϥʔʹؾ͖ͮʹ͍͘ ৽ணίϯςϯπʹؔ࿈ͨ͠ಈ࡞֬ೝ͕͠ʹ͍͘ Ϣʔβͷମݧͱ͸ҟͳΔ

  21. ' ' ' # # # ຊ൪%# ։ൃ%# NBTUFS TMBWF

    SFBE X SJUF ։ൃऀ .Z42- .Z42- ݱࡏ ։ൃऀ͸ৗʹຊ൪ͷ࠷৽σʔλ͕ೖͬͨDBͰ։ൃ
  22. Ͳ͏΍Δͷ͔ ݒ೦఺ slave ʹॻ͖ࠐΜͩΒΩʔিಥ౳Ͱ
 ϨϓϦέʔγϣϯΤϥʔʹͳΔͷͰ͸ʁ id ͕ຊ൪ͱͣΕͯ݁ہ࢖͑ͳ͍σʔλʹͳΔͷͰ͸ʁ

  23. JE OBNF  ΧϨʔ  ͔Β͋͛  ೑͡Ό͕ JE OBNF

     ΧϨʔ  ͔Β͋͛  ೑͡Ό͕  ͦ͹ '# ຊ൪%# ։ൃ%# */4&35 ϨϓϦέʔγϣϯ  ϥʔϝϯ ௨ৗɺslave ʹॻ͖ࠐΜͰ͠·͏ͱ AUTO_INCREMENT ͍ͯ͠Δ id ͕িಥ͢Δ
  24. JE OBNF  ΧϨʔ  ͔Β͋͛  ೑͡Ό͕ JE OBNF

     ΧϨʔ  ͔Β͋͛  ೑͡Ό͕  ͦ͹  ͏ͲΜ  ੜᇙম͖ '# ຊ൪%# ։ൃ%# */4&35 ϨϓϦέʔγϣϯ AUTO_INCREMENT ʹڊେͳΦϑηοτΛઃఆ͢Δ͜ͱͰ ຊ൪ͱিಥ͠ʹ͘͘͢Δ  ϥʔϝϯ
  25. JE OBNF  ΧϨʔ  ͔Β͋͛  ೑͡Ό͕ JE OBNF

     ΧϨʔ  ͔Β͋͛  ೑͡Ό͕  ͦ͹  ͏ͲΜ  ੜᇙম͖ ຊ൪%# ։ൃ%# εςʔτϝϯτϕʔε ϨϓϦέʔγϣϯ ࠷৽ͷ݅Λʮম೑ʯʹมߋ UPDATE recipes SET name=‘ম೑’ ORDER BY id DESC LIMIT 1 ম೑ ম೑ εςʔτϝϯτϕʔεϨϓϦέʔγϣϯͰ͸ ։ൃ DB ͷσʔλ͕յΕ΍͍͢
  26. JE OBNF  ΧϨʔ  ͔Β͋͛  ೑͡Ό͕ JE OBNF

     ΧϨʔ  ͔Β͋͛  ೑͡Ό͕  ͦ͹  ͏ͲΜ  ੜᇙম͖ ຊ൪%# ։ൃ%# ߦϕʔε ϨϓϦέʔγϣϯ ࠷৽ͷ݅Λʮম೑ʯʹมߋ UPDATE recipes SET name=‘ম೑’ ORDER BY id DESC LIMIT 1 ম೑ ম೑ ߦϕʔεϨϓϦέʔγϣϯʹ͢Δ͜ͱͰ ։ൃ DB ͷσʔλ͕յΕʹ͘ͳΔ
  27. ຊ൪%# ։ൃ%# ߦϕʔε ϨϓϦέʔγϣϯ εςʔτϝϯτϕʔε ϨϓϦέʔγϣϯ CJOMPH ม׵༻%# ߦϕʔεϨϓϦέʔγϣϯͰ͸ɺ όΠφϦϩά΍సૹྔ͕ڊେʹͳΓɺຊ൪ʹෛՙ͕͔͔ΔͨΊ

    ࣮ࡍʹ͸தؒ DB Λ༻ҙ͠όΠφϦϩάΛม׵͍ͯ͠Δ
  28. ϨϓϦέʔγϣϯఀࢭରࡦ΋ඞཁ ෆ੔߹͸ى͖ʹ͘͘Ͱ͖Δ͕ɺܾͯ͠׬ᘳͰ͸ͳ͍ͷͰ
 ϨϓϦ͕ΤϥʔͰࢭ·Δ͜ͱ΋͋Δ slave_skip_errors = ON Λઃఆͭͭ͠ɺ ఀࢭͨ͠Β skip ͯ͠࠶։͢Δ؂ࢹεΫϦϓτΛӡ༻

    ʢslave_skip_errors͚ͩͰ͸ skip ͞Εͳ͍Τϥʔ͕͋ΔͨΊ…ʣ
  29. ' ' ' # # # ຊ൪%# ։ൃ%# NBTUFS TMBWF

    SFBE X SJUF ։ൃऀ .Z42- .Z42- ։ൃऀ͸ৗʹຊ൪ͷ࠷৽σʔλ͕ೖͬͨDBͰ։ൃ
  30. ຊ൪؀ڥͰ։ൃ͢Δ w

  31. &BUZPVSPXOEPHGPPE ࣗ෼ͨͪͷαʔϏε͸ࣗ෼͕ͨͪϢʔβʹͳΔ΂͖ ♥

  32. ඇϩάΠϯ ελοϑϢʔβ ͱͯ͠ϩάΠϯ ελοϑ͕ϩάΠϯ͢Δͱɺ ։ൃதͷϕʔλػೳ͕͍ͭ͘΋༗ޮʹͳΔ

  33. ϕʔλػೳ ϦϦʔεൣғΛࢦఆͯ͠ެ։ ެ։ൣғͷྫ ελοϑͷΈʹެ։ ςετࢀՃϢʔβʹͷΈެ։ શମͷ10%ͷϢʔβʹެ։

  34. αʔϏεͷՁ஋͸࢖Θͳ͍ͱ෼͔Βͳ͍ ͦͷՁ஋ͷԾઆ͸ਖ਼͔ͬͨ͠ͷ͔ʁ ຊ൪ʹϦϦʔε͠ͳ͍ͱɺϢʔβʹ࢖ͬͯ΋Β͏͜ͱ͕Ͱ͖ͳ͍ ຊ൪ʹϦϦʔε͢Δʹ͸ຊ൪ͷ඼࣭ͷ
 ίʔυʢύϑΥʔϚϯε౳ʣʹ࢓্͛ͳ͚Ε͹ͳΒͳ͍ʁ ˠඞཁͷͳ͍ػೳΛ࡞Γ͜ΜͰ͠·͏Մೳੑ͕͋Δ

  35. ૣࣦ͘ഊΛ͢Δ ίʔυͷ࡞ΓࠐΈʹ࣌ؒΛ͔͚ΔΑΓɺ ૉૣ͘ެ։ͯ͠ԾઆΛݕূ͢ΔͨΊʹ࣌ؒΛ࢖͏΂͖ *

  36. $IBOLP ຊ൪؀ڥͰͷτϥΠˍΤϥʔΛࢧԉ͢Δ Rails ༻ gem Unit ͱ͍͏୯ҐͰطଘίʔυ΁ͷύονΛهड़ ඼࣭ͷ௿͍ίʔυΛຊ൪ʹ҆શʹग़ͤΔ IUUQTHJUIVCDPNDPPLQBEDIBOLP +

  37. " # طଘͷίʔυ A ΛɺελοϑϢʔβͷΈʹରͯ͠ ϕʔλ൛ͷίʔυ B ʹஔ͖׵͍͑ͨ ͨͩ͠ɺB ͸๯ݥతͳ࣮૷ͳͷͰɺྫ֎͕ൃੜ͢Δ͔΋͠Εͳ͍

    طଘͷ$POUSPMMFSͷίʔυ ϕʔλ൛ͷίʔυ
  38. ελοϑͳΒ# #Ͱྫ֎͕ى͖ͨΒ" ελοϑҎ֎ͳΒ" ϑϥάͰ෼ذ͍ͤͯ͘͞ͱίʔυ͕ԚΕ͍ͯ͘

  39. ϕʔλػೳͷ6OJU طଘͷ$POUSPMMFSͷίʔυ " # Chanko Ͱ͸ɺUnit ͱ͍͏ϑΝΠϧʹϕʔλػೳͷϩδοΫΛهड़͢Δ invoke ৚݅Λຬͨͨ͠৔߹ʹɺطଘϩδοΫ (A)

    ͷ୅ΘΓʹ Unit (B) ͕࣮ߦ͞ΕΔ B ͕ྫ֎Λىͨ͜͠৔߹͸ɺݩͷ A ͕࣮ߦ͞ΕΔͨΊɺϢʔβʹ͸Τϥʔ͕ฦΒͳ͍ JOWPLF৚݅
  40. ແࣄʹՁ஋͕ೝΊΒΕͨΒ ຊ൪ͷ඼࣭ͷίʔυʹ࢓্͛Δ طଘίʔυΛॻ͖׵͑ɺUnit ϑΝΠϧΛফ͢
 ʢ௨শ Un-chankoʣ

  41. $IBOLPͷӡ༻ঢ়گ 2011: Chanko ϦϦʔε + ಋೖ 2015: 200+ Chanko Units

    • εςʔδϯά༻ͷαʔό͸ଘࡏ͢Δ͕ɺར༻ස౓͸௿͍ • ։ൃதͷ΋ͷΛຊ൪ʹग़͢จԽ͕Ͱ͖͍ͯΔ
  42. ςετ

  43. ΫοΫύουͱ34QFD 1800+ files 21000+ examples (test cases) 7 min ,

  44. 5FTUTNFMMT ࣮ߦ͕࣌ؒ௕͍ յΕ΍͍͢ʢίʔυͷมߋʹऑ͍ʣ Fail ͠΍͍͢ ࣮ߦ؀ڥ΁ͷґଘ -

  45. 3334QFD

  46. . 3334QFD ଎ͯ͘ɾ҆ͯ͘ɾ҆ఆͨ͠$* ෳ਺ͷ Spot Instance Λ࢖ͬͯ RSpec Λฒྻ࣮ߦ ڧྗͳϑΥʔϧττϨϥϯε

    IUUQTHJUIVCDPNDPPLQBESSSTQFD +
  47. // / / TMBWF TMBWF XPSLFS XPSLFS XPSLFS ʜ /

    ʜ ʜ ʜ / / / / NBTUFS ////ʜ
  48. $*XPSLFS୆਺ͷભҠ ۀ຿࣌ؒ֎͸୆਺ΛݮΒͯ͠
 ίετ࡟ݮ

  49. &$4QPU*OTUBODF ͳΔ΂͘ϋΠεϖοΫͳΠϯελϯεΛ࢖͍͍͕ͨߴՁ →Spot Instance ͷར༻ 0

  50. &$4QPU*OTUBODF ʮ1࣌ؒ͋ͨΓͷ࠷େೖࡳՁ֨ʯΛࢦఆͯ͠ىಈ͢Δ ࢦఆͨ͠ʮ࠷େೖࡳՁ֨ʯΑΓ૬৔Ձ͕͚֨҆Ε͹ىಈ ىಈதʹ૬৔Ձ͕֨ʮ࠷େೖࡳՁ֨ʯΛ্ճͬͨ৔߹ɺ
 Πϯελϯε͸γϟοτμ΢ϯ͞ΕΔ ૬৔Ձ֨͸ OnDemand Ձ֨ΑΓߴ͘ͳΔ͜ͱ΋͋Δ ૬৔Ձ֨͸ AZ

    ͝ͱʹΑͬͯ΋ҟͳΔ
  51. ౦ژϦʔδϣϯͷͱ͋Δ";ʹ͓͚Δ 4QPU1SJDF DYMBSHF 0OEFNBOE I 3*ZBMMVQGSPOU I 

  52. DYMBSHF DYMBSHF DYMBSHF ˺ ˺ DYMBSHF DYMBSHF DYMBSHF ˺ ˺

    Ұ൪ίετύϑΥʔϚϯε͕͍͍
 ΠϯελϯεΛࣗಈతʹબ୒
  53. ϑΥʔϧττϨϥϯε ͍͔ʹͯ͠GBJM͠ʹ͍͘$*ʹ͢Δ͔ ·Εʹࣦഊ͢ΔFYBNQMFʹରͯ͠ɿ ۭ͍͍ͯΔ worker Ͱࣗಈతʹ࠶࣮ߦ
 Ұ౓Ͱ΋ success ͢Ε͹ success

    ͱͯ͠ѻ͏ 4QPU*OTUBODFͷࣗಈγϟοτμ΢ϯʹରͯ͠ɿ ଞͷ worker Ͱࣗಈతʹ࠶࣮ߦ ผλΠϓͷΠϯελϯεΛىಈ͠࠶࣮ߦ
  54. ׂΕ૭ཧ࿦ ݐ෺ͷ૭ׂ͕Ε͍ͯΔ֗͸ɺ࣏͕҆ѱԽ͢Δ ܰඍͳ൜ࡑΛపఈతʹऔΓక·Δ͜ͱͰ
 ڟѱ൜ࡑΛ΋཈ࢭͰ͖Δͱ͢Δ؀ڥ൜ࡑ্ֶͷཧ࿦ IUUQKBXJLJQFEJBPSHXJLJׂΕ૭ཧ࿦ -

  55. $*͕ʮׂΕ૭ʯʹͳΒͳ͍Α͏ʹ ܰඍͳ͏ͪʹൃݟ͠ɺରॲ͢Δ • Ϗϧυ͕࣌ؒ௕͘ͳΔ • ͚ͯ͜Δςετͷ์ஔ • pending ঢ়ଶͳςετͷ์ஔ 1

  56. ௨஌ Fail ͨ͠ example ͸࡞ऀΛ blame ͯ͠νϟοτͰ௨஌ Fail ͬ͠ͺͳ͠ʹͤ͞ͳ͍

  57. ·Εʹ'BJM͢ΔςετΛݟ͚ͭΔ lBMMOJHIU$*z ۀ຿࣌ؒ֎ʹͣͬͱճ͠ଓ͚Δ CI success ཰͕௿͍ͱԿ͔͕͓͔͍͠

  58. ໨ඪ ෼Ҏ಺ ෼Ҏ্͔͔ͬͨΒ௨஌ $*ͷϏϧυ࣌ؒΛ؂ࢹ

  59. QFOEJOHʹͤͬ͞ͺͳ͠ͷςετͷ࡞ऀʹࣗಈ௨஌ IUUQTHJUIVCDPNDPPLQBEQFOEBYFT +

  60. $*ӡ༻ͷ·ͱΊ • ༏Εͨ CI γεςϜΛ࡞Δ͜ͱΑΓɺ
 Ͳ͏ӡ༻͢Δ͔͕ॏཁ • Ϗϧυ࣌ؒɾ௨ա཰ɾίετͳͲͷ
 ࢦඪΛఆٛͯ͠؂ࢹ͠ɺ
 վળ͍ͯ͘͠

    • ׂΕ૭ʹ͠ͳ͍ 2
  61. σϓϩΠ

  62. + TVDDFTT -(5. QVMMSFRVFTU NFOUJPO EFQMPZ &$ (JU)VC &OUFSQSJTF #

    EFWFMPQFS # SFWJFXFS $* +FOLJOT NFSHF
  63. σϓϩΠϧʔϧʢҰ෦ʣ • CI Λύεͨ͠ϦϏδϣϯͷΈσϓϩΠͯ͠Α͍ • σϓϩΠ͸ίʔυΛ push ͨ͠։ൃऀࣗ਎͕ߦ͏ • Ӧۀ࣌ؒ಺ͷΈσϓϩΠՄೳ

    • σϓϩΠޙ͸։ൃऀ͕ಈ࡞֬ೝ͠ɺ
 ෆ۩߹Λݟ͚ͭͨΒ͙͢ʹϩʔϧόοΫ͢Δ
  64. σϓϩΠʹॏཁͳ͜ͱ • ଐਓతͰͳ͍͜ͱ • ਖ਼֬Ͱ͋Δ͜ͱ • ϩʔϧόοΫͰ͖Δ͜ͱ • े෼ʹ଎͍͜ͱ 3

  65. ௚ۙिؒͷσϓϩΠʹ͔͔ͬͨ࣌ؒ ฏۉඵ  IPTUT

  66. $BQJTUSBOP࣌୅ʢʙʣ capistrano2 + rsync_with_remote_cache

  67. $BQJTUSBOPσϓϩΠͱ଎౓ 1୆͔Βશ୆ʹ ssh + rsync σϓϩΠର৅ϗετ୆਺͕૿͑Δͱ஗͘ͳ͍ͬͯ͘

  68. σϓϩΠର৅ϗετશ୆ʹTTI STZOD ˠσϓϩΠ଎౓ͷϘτϧωοΫʹ $BQJTUSBOP # / / / / /

    / / STZOD
  69. .BNJZB

  70. .BNJZB ϋΠεέʔϥϒϧͳߴ଎σϓϩΠγεςϜ σϓϩΠର৅ϗετΛ serf ͰΫϥελϦϯά Amazon S3 ܦ༝Ͱ഑෍ Capistrano ޓ׵ͷσΟϨΫτϦߏ੒

    IUUQTHJUIVCDPNTPSBINBNJZB +
  71. / $* UBSCBMM 4 $*͕௨ͬͨϦϏδϣϯͷίʔυ͸ UBSCBMMͱͯ͠4ʹૹΒΕΔ

  72. / / / / / / / / $*͕௨ͬͨϦϏδϣϯͷUBSCBMM͸ શ୆͕ৗʹࣗಈͰQVMM͍ͯ͠Δ

    ʢ͜ͷ࣌఺Ͱ͸·ͩຊ൪ͷίʔυ͸੾ΓସΘ͍ͬͯͳ͍ʣ /
  73. σϓϩΠͷࢦྩ͸4FSGΠϕϯτͱͯ͠(PTTJQϓϩτίϧͰ఻೻ # !IVCPUEFQMPZQSPEVDUJPO

  74. શ୆ͷϦϏδϣϯ͕੾ΓସΘΔ ʢϑΝΠϧ഑෍͸͋Β͔͡Ί׬͍ྃͯ͠ΔͨΊɺߴ଎ʹ׬ྃ͢Δʣ / / / / / / / /

    / / / / / / / / #
  75. .BNJZBͷεέʔϥϏϦςΟ Mamiya ͸σϓϩΠର৅ϗετ૿Ճʹରͯ͠εέʔϥϒϧ ϗετ͕૿Ճͯ͠΋ʢ΄ͱΜͲʣ஗͘ͳΒͳ͍ ϑΝΠϧͷ഑෍ɿ S3 ͷεέʔϥϏϦςΟΛར༻ શ୆΁ͷϦϏδϣϯ੾Γସ͑ࢦྩɿ Serf ΠϕϯτΛར༻

  76. .BNJZBʹΑΔσϓϩΠ࣌ؒ୹ॖޮՌ ෼ˠඵ DBQJTUSBOP NBNJZB DBQJTUSBOP NBNJZB

  77. ͓ΘΓʹ

  78. ⚒ ։ൃ σϓϩΠ ςετ

  79. ։ൃͷ͠΍͢͞Λอͭ ׂΕ૭Λ࡞Βͳ͍ͨΊʹ͸ɺ੹೚ऀͱࢦඪ͕ඞཁ 4

  80. ʮ։ൃ͠΍͢͞ʯͷՁ஋ • ։ൃ͔ΒσϓϩΠ·ͰͷαΠΫϧ͕े෼ʹ଎͚Ε͹ɺ
 ʮຊ൪؀ڥΛ࢖ͬͨ։ൃʯ͕࣮ݱͰ͖Δ →Ϣʔβͱಉ͡ମݧͷதͰ։ൃ͢Δ • ։ൃ͠΍͢͞ʹ౤ࢿ͢ΔՁ஋͸े෼ʹ͋Δ • ݁Ռͱͯ͠։ൃ૊৫΋αʔϏε΋݈શͳঢ়ଶΛอͯΔ 'JO