Slide 1

Slide 1 text

࣮ફʂϚΠΫϩαʔϏε /BPZPTIJ"JLBXB !BXBLJB 43&5FDI5BMLT

Slide 2

Slide 2 text

✤ Wantedlyʹ͸4೥2ϲ݄ɻ4ਓͷ࣌ʹೖͬͨɻ ✴ Web։ൃ => ΠϯϑϥϦʔμʔ ✴ ػցֶश΋࠷ۙ΍ͬͯ·͢ ✤ લ৬ɿGoogleͰݕࡧͷνʔϜ ✤ Qiita݁ߏॻ͍ͯ·͢ ࣗݾ঺հ

Slide 3

Slide 3 text

Wantedlyʹ͍ͭͯ 1 2 3 ྫ: ؾͷ߹͏஥ؒͱ΍Γ͍ͨγΰτΛ୳ͤΔαʔϏε ϛογϣϯ:ʮγΰτͰίίϩΦυϧਓΛ૿΍͢ʯ

Slide 4

Slide 4 text

Feed Sync Tools ϏδωεSNSͱͯ͠ͷWantedly ಇ͘ਓશͯͷϓϥοτϑΥʔϜ΁

Slide 5

Slide 5 text

Feed - γΰτͰ΍͍ͬͯΔ͜ͱΛൃ৴

Slide 6

Slide 6 text

Feed - ֤ࣾͷαΠτʹ΋഑ஔՄೳ ֤͕ࣾɺࣾ಺৘ใ Λൃ৴͠΍͍͢ܗ ʹ ʮ͸ͨΒ͘ʯ ΛΦʔϓϯʹʂ

Slide 7

Slide 7 text

Tools - πʔϧͷޱίϛ / Ϛʔέοτ

Slide 8

Slide 8 text

Sync - άϧʔϓϝοηʔδ ࣾ֎ͷਓͱͷίϛϡχέʔγϣϯ΋ޮ཰తʹ

Slide 9

Slide 9 text

1. ͲΜͲΜ৽͍͠αʔϏεΛ
 ఏڙ͍͖͍ͯͨ͠ 2. ޮ཰։ൃ͢ΔͨΊʹɺࣗ༝ʹ
 ݴޠ΍ArchitectureΛબͼ͍ͨ 3. গਓ਺νʔϜͰߦ͍͖͍ͬͯͨ • ΤϯδχΞ: 25ਓ • Πϯϑϥ: 3ਓ ΠϯϑϥʹٻΊΒΕ͍ͯΔ͜ͱ Go ʮطଘʯΑΓʮ৽نʯͷํ͕େมʹ python

Slide 10

Slide 10 text

SREʹ͍ͭͯ

Slide 11

Slide 11 text

✤ SRE͸ 2003 ೥ʹ࢝·ͬͨ ✤ αΠτͷ৴པੑ޲্ʹ஫ྗ͍ͯ͠Δgoogle ͷ։ൃऀʹΑͬͯߏ੒͞ΕΔ ✤ ʮجຊతʹɺSRE͸ιϑτ΢ΣΞΤϯδχ ΞʹΦϖϨʔγϣϯʹؔ͢ΔػೳઃܭΛཔ Ήͱى͜Δ͜ͱʯ SRE by Google 8IFO43&pSTUTUBSUFEJO JUXBTDPNQPTFEPGBCVODIPG(PPHMFEFWFMPQFST XIPDBSFEBMPUBCPVUNBLJOHUIFTFSWJDFSFMJBCMF*UIJOLUIFDMFBSFTUTVNNBSZJT GSPN#FO5SFZOPS'VOEBNFOUBMMZ <43&>JTXIBUIBQQFOTXIFOZPVBTLBTPGUXBSF FOHJOFFSUPEFTJHOBOPQFSBUJPOTGVODUJPO IUUQTXXXRVPSBDPN8IBUJTJUMJLFUPCFB4JUF3FMJBCJMJUZ&OHJOFFS43&BU(PPHMF

Slide 12

Slide 12 text

✤ ڞ௨఺ ✴ ͲͪΒ͔ͱݴ͏ͱɺιϑτ΢ΣΞΤϯδχΞ͕͋ΓͷΠ ϯϑϥΤϯδχΞ ✴ ଓʑͱ৽ػೳ͕௥Ճ͞ΕΔαʔϏεΛɺ΄΅Ұఆͷਓ਺ Ͱ͞͹͚ΔΑ͏ʹ͢Δ ✴ ίʔυΊͬͪΌॻ͘(ίʔυʹͳͬͯͳ͍΋ͷ͸جຊධ Ձ͠ͳ͍) ✤ ૬ҧ఺ ✴ ΤϯδχΞ: αʔϏεͷ੒௕͕໨ඪ
 Πϯϑϥ: ΤϯδχΞͷੜ࢈ੑ޲্͕໨ඪ
 <=> (SRE: αΠτͷ৴པੑͷ୲อ͕໨ඪ) WantedlyΠϯϑϥΤϯδχΞͱͷൺֱ

Slide 13

Slide 13 text

ϚΠΫϩαʔϏεͰԿ͕خ͍͔͠ εέʔϧͤ͞΍͍͢ ػಈతͳ૊৫ ʢίϯ΢ΣΠͷ๏ଇʣ ো֐ͷӨڹ͕෦෼త ݸผσϓϩΠ ࢖༻ٕज़ɾݴޠ ͕ࣗ༝ʹ ϞδϡʔϧԽ มԽʹڧ͍ ࣺͯ΍͍͢

Slide 14

Slide 14 text

ϚΠΫϩαʔϏεͰԿ͕خ͍͔͠ εέʔϧͤ͞΍͍͢ ػಈతͳ૊৫ ʢίϯ΢ΣΠͷ๏ଇʣ ো֐ͷӨڹ͕෦෼త ݸผσϓϩΠ ࢖༻ٕज़ɾݴޠ ͕ࣗ༝ʹ ϞδϡʔϧԽ มԽʹڧ͍ ࣺͯ΍͍͢ ͱΓ͋͑ͣօ͍͍ͱࢥͬͯΔ ͚Ͳɺ࣮ࡍ΍Δͷେม…

Slide 15

Slide 15 text

✤ Docker͸1೥൒લ͔Βಋೖ ✴ ཧ༝: Heroku͔ΒͷҠߦ ✴ σϓϩΠ࣌ؒΛ୹͔ͨͬͨ͘͠ ✤ OS΋ܦݧ͔ΒશͯCoreOS ✤ ͱ͸͍͑ɺMonolithic Railsͩͬͨ ✴ ͦΜͳαʔϏεͳ͔ͬͨ͠… ✴ ࠓ͸αʔϏε΋૿͑ɺ࣮ࡍʹϚΠΫϩαʔϏε Խ͖͍ͯͯ͠Δ Wantedlyͷݱঢ়

Slide 16

Slide 16 text

Ͳ͏ͳͬͨΒ ϚΠΫϩαʔϏε͔

Slide 17

Slide 17 text

1. ͜ͷ࣌఺ΑΓɺશͯͷνʔϜ͸αʔϏεΠϯλʔϑΣʔεΛ௨ͯ͡શͯ ͷσʔλͱػೳΛެ։͢Δ͜ͱ 2. ֤νʔϜ͸֤ʑͦͷΠϯλʔϑΣʔεΛ௨ͯ͡௨৴͠ͳ͚Ε͹ͳΒͳ͍ 3. ͦͷଞͷશͯͷϓϩηεؒ௨৴͸ڐՄ͞Εͳ͍ɻμΠϨΫτϦϯΫɺ ଞͷνʔϜͷσʔλιʔε͔Β௚઀σʔλΛಡΉ͜ͱɺϝϞϦڞ༗Ϟ σϧɺόοΫυΞɺશͯΛې͡ΔɻωοτϫʔΫӽ͠ͷαʔϏεΠϯλʔ ϑΣʔεΛܦ༝ͨ͠௨৴͚͕ͩڐՄ͞ΕΔ 4. ࢖༻͢Δٕज़͸໰Θͳ͍ɻ HTTP ɺ Corba ɺ Pubsub ɺ ΧελϜϓ ϩτίϧɺԿͰ΋ྑ͍ɻ Bezos ͸ؾʹ͠ͳ͍ 5. શͯͷαʔϏεΠϯλʔϑΣʔε͸ɺྫ֎ͳ͘ɺ֎෦ʹެ։ՄೳͳΑ͏ ʹθϩ͔Βઃܭ͞Εͳ͚Ε͹ͳΒͳ͍ɻ͢ͳΘͪɺνʔϜ͸શੈքͷ σϕϩούʹ޲͚ͯΠϯλʔϑΣʔεΛެ։͢Δ͜ͱ͕Ͱ͖ΔΑ͏ɺઃ ܭ͠ɺܭը͠ͳ͚Ε͹ͳΒͳ͍ɻྫ֎͸ແ͍ 6. ͦ͏͠ͳ͍ऀ͸ղޏ͞ΕΔ 2002೥ʹAmazonͷࣾ௕͕ग़ͨ࢘͠ྩ http://anond.hatelabo.jp/20111018190933

Slide 18

Slide 18 text

1. ͜ͷ࣌఺ΑΓɺશͯͷνʔϜ͸αʔϏεΠϯλʔϑΣʔεΛ௨ͯ͡શͯ ͷσʔλͱػೳΛެ։͢Δ͜ͱ 2. ֤νʔϜ͸֤ʑͦͷΠϯλʔϑΣʔεΛ௨ͯ͡௨৴͠ͳ͚Ε͹ͳΒͳ͍ 3. ͦͷଞͷશͯͷϓϩηεؒ௨৴͸ڐՄ͞Εͳ͍ɻμΠϨΫτϦϯΫɺ ଞͷνʔϜͷσʔλιʔε͔Β௚઀σʔλΛಡΉ͜ͱɺϝϞϦڞ༗Ϟ σϧɺόοΫυΞɺશͯΛې͡ΔɻωοτϫʔΫӽ͠ͷαʔϏεΠϯλʔ ϑΣʔεΛܦ༝ͨ͠௨৴͚͕ͩڐՄ͞ΕΔ 4. ࢖༻͢Δٕज़͸໰Θͳ͍ɻ HTTP ɺ Corba ɺ Pubsub ɺ ΧελϜϓ ϩτίϧɺԿͰ΋ྑ͍ɻ Bezos ͸ؾʹ͠ͳ͍ 5. શͯͷαʔϏεΠϯλʔϑΣʔε͸ɺྫ֎ͳ͘ɺ֎෦ʹެ։ՄೳͳΑ͏ ʹθϩ͔Βઃܭ͞Εͳ͚Ε͹ͳΒͳ͍ɻ͢ͳΘͪɺνʔϜ͸શੈքͷ σϕϩούʹ޲͚ͯΠϯλʔϑΣʔεΛެ։͢Δ͜ͱ͕Ͱ͖ΔΑ͏ɺઃ ܭ͠ɺܭը͠ͳ͚Ε͹ͳΒͳ͍ɻྫ֎͸ແ͍ 6. ͦ͏͠ͳ͍ऀ͸ղޏ͞ΕΔ 2002೥ʹAmazonͷࣾ௕͕ग़ͨ࢘͠ྩ http://anond.hatelabo.jp/20111018190933 = APIͰશͯΛߦ͑

Slide 19

Slide 19 text

Microservices׬੒ܗ API Gateway Swift Android Java React Angular API Request API Request Kong Kubernetes Go Rails Python api.wantedly.com /bot /v2 /v1 Mobile PC

Slide 20

Slide 20 text

Microservicesͷલ (Monolithic) Swift Android Java Rails API Request Render HTML Rails www.wantedly.com Mobile PC

Slide 21

Slide 21 text

Microservices׬੒ܗ API Gateway Swift Android Java React Angular API Request API Request Kong Kubernetes Go Rails Python api.wantedly.com /bot /v2 /v1 Mobile PC

Slide 22

Slide 22 text

ϚΠΫϩαʔϏεͷ ɹɹɹਁಁͷͤ͞ํ

Slide 23

Slide 23 text

ϚΠΫϩαʔϏεͷਁಁͷͤ͞ํ͸ ঎඼։ൃ 1. χʔζͷൃ۷ 2. ࢼ࡞඼։ൃ 3. େྔੜ࢈ WantedlyͰͷϚΠΫϩαʔϏεԽ 1. APIͷՁ஋Λ͋͛Δ 2. ͍͍APIΛ࡞ΕΔΑ͏ʹ͢Δ 3. APIΛ࡞Γ΍͘͢ ঎඼։ൃʹࣅ͍ͯΔ

Slide 24

Slide 24 text

"1*ͷՁ஋Λ͋͛Δ

Slide 25

Slide 25 text

1. Rails͚ͩͲJavascriptΛnpmͰ؅ཧ 2. React.jsͷϜʔϒϝϯτΛ࡞Δ • Redux, Immutable.js ΋Ұॹʹೖͬͨ • ผʹAngular.jsͰ΋ྑ͍ 3. ࣾ಺ษڧձͰ͍Ζ͍Ζ
 ޿Ίͯ΋Β͏ • ࣾ಺ษڧձ΋3ճ • ֎෦ɺϒϩά΋ ΞϓϦଆ͕APIΛݩʹRender͢ΔΑ͏ʹ

Slide 26

Slide 26 text

ϓϩμΫτΤϯδχΞͷԠԉ ʢͳʹ΋ͯ͠ͳ͍ʣ ΠϯϑϥΤϯδχΞͷͨ͜͠ͱ

Slide 27

Slide 27 text

Ͱ΋ɺͦΕ͕Ұ൪ॏཁʂʂ

Slide 28

Slide 28 text

WHY: ඞཁͳ͍΋ͷʹ࣌ؒ͸औΕͳ͍

Slide 29

Slide 29 text

1. ࠷ۙྲྀߦΓͷػցֶशͱབྷΊ 2. ߴ଎Խ/লϝϞϦ͕ॏཁʹͳ͖ͬͯͨ͜ͱͱབྷΊ ͍ͭͰʹ Python Go ಋೖͯ͠·͢ɻ

Slide 30

Slide 30 text

͍͍"1*Λ࡞ΕΔΑ͏ʹ

Slide 31

Slide 31 text

1. ͍͍APIΛௐࠪ • Heroku API Design, Facebook APIͷભҠ͕ͱͯ΋ࢀߟʹ 2. Heroku API Design Ͱجૅशಘ • όʔδϣϯ͸ϔομͰࢦఆ • ϖʔδωʔγϣϯ৘ใ΋ϔομʹ • Ϧιʔεͷωετ͸ /users/:id/posts ͷϨϕϧ·Ͱ 3. Facebook API Ͱ࣮ફٕज़शಘ • Batch APIͱ͍͏ߟ͑ํ • ϑΟʔϧυࢦఆ͸ඞਢʹ • /me?fields=id,name 4. ࣮ࡍʹখ͘͞ࢼ࡞඼Λ࡞Δ ͍͍APIͷௐࠪͱࢼ࡞඼ͷ࡞੒

Slide 32

Slide 32 text

1. APIͷυΩϡϝϯτ͸ API Blueprint͕Αͦ͞͏ • JSON Schema͸ಡΈʹ͘͘ϝϯς͕େม • Swagger͸ϚΠΫϩαʔϏεʹ͸ߴػೳ͗͢ 2. DreddͰجຊతͳΤϯυϙΠϯτͷςετ΋Ͱ͖Δ • ݴޠʹΑΒͳ͍ͷ͕ྑ͍ 3. GoͰwebmockςετΛॻ͘ͷ͸͔ͳΓେม • ؔ਺Λஔ͖׵͑ΒΕͳ͍ͷͰɺͲ͔͜ͰҾ਺౉͠ͷඞཁ͕… 4. ΍Γա͗෦෼ͷൃݟ • FacebookͷfieldsΛશ෦໌ࣔࢦఆ͠ͳ͍ͱ͍͚ͳ͍ͷ͸΍Γ͢ ͗… ࢼ࡞඼࡞੒ͰΘ͔ͬͨ͜ͱ

Slide 33

Slide 33 text

"1*Λ࡞Γ΍͘͢

Slide 34

Slide 34 text

1. Auto Generatorͷ࡞੒ 2. Integrationςετ؆ུԽͷͨΊͷπʔϧ 3. ύοͱαʔϏεΛ্ཱͪ͛ΒΕΔΠϯϑϥ 4. ৭ΜͳAPIΛ౷߹؅ཧ APIΛ࡞Γ΍͘͢

Slide 35

Slide 35 text

Auto Generator ͷ࡞੒ WHY • MicroʹͰ͖ΔRailsతͳ΋ͷ͕ཉ͍͠ • ࣮͸gRPC/Protocol Buffers͕ιϨͩͬͨΓ… gRPC • αʔόαΠυΛࣗಈੜ੒ • ΫϥΠΞϯτଆ΋ࣗಈੜ੒ • go, C++, Java, ruby, … ios, android, js ΋ • ໰୊: • ProtocolBuffers͕JSONʹൺ΂ͯ͸΍ͬͯͳ͍ • Ұൠతʹ࣌୅͸RPC(ಈࢺత)ΑΓ͔͸REST(໊ࢺత)

Slide 36

Slide 36 text

ࠓͭͬͯ͘·͢ - wantedly/apig ࢓༷ • Input: Gormͱ͍͏ORϚούʔܗࣜͰॻ͘Goͷstruct • Output: αʔόʔίʔυҰࣜ(ςετɺυΩϡϝϯτ෇͖) package models import "time" type User struct { ID uint `gorm:"primary_key;AUTO_INCREMENT" json:"id"` Name string `gorm:"unique" json:"name,omitempty"` Emails []Email `gorm:"unique" json:"emails"` CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` }

Slide 37

Slide 37 text

wantedly/apig - ੜ੒͞ΕΔυΩϡϝϯτ

Slide 38

Slide 38 text

Integrationςετͷ؆ུԽ WHY • ϚΠΫϩαʔϏε͸APIϦΫΤετ͕ଟ͘ͳΔ • ͦ͜Λmockͯ͠ςετ͢Δͷ͕ఆੴ • ஫: શ͘mockΛ࢖Θͳ͍ͰϦΫΤετͪ͠Ό͑೿΋ RudyͰ͸ • webmock, vcrͱ͍͏΋ͷ͕͋Δ • ॳճ: ΄ΜͱʹϦΫΤετͯ͠ɺ݁ՌΛه࿥ • 2ճ໨Ҏ߱: ه࿥ͨ݁͠ՌΛ࠶ੜ • Ruby͸ϝιου࣮૷Λಈతʹॻ͖׵͑ΒΕΔͷͰͰ͖Δ GoͰ͸ɺͰ͖ͳ͍

Slide 39

Slide 39 text

ϓϩΩγͰvcrΛ࣮ݱ - webmock-proxy ࣗ෼ͷ αʔϏε ֎෦ αʔϏε ϓ ϩ Ω γ ϦΫΤετΛ ه࿥ ରԠ͢Δ ϨεϙϯεΛ ه࿥ ϓϩΩγ͕ ݁ՌΛฦ͢ ॳճ ̎ճ໨

Slide 40

Slide 40 text

ͺͬͱαʔϏεΛ্ཱͪ͛Δ Docker / Kubernetes Ͱ؅ཧ • ৄࡉ͸ɺ·ͨผͷػձʹɻطʹز͔ͭൃදͯ͠·͢ɻ WHY • ϚΠΫϩαʔϏενʔϜ͸ΠϯϑϥͷґཔΛίϛϡχέʔ γϣϯͰ͸ͳ͘APIͰߦ͏ HOW • ͦͷAPIͷϑΥʔϚοτ͕Dockerfile, k8s ͷ rc.yml • ΠϯλʔϯͰ΋1೔Ͱॻ͚Δ͜ͱ͸࣮ূࡁΈ • ΤϯδχΞ͸ɺٕज़ελοΫΛબ΂Δ • Πϯϑϥ͸ΫϥελΛඞࢮʹ؅ཧ • KubernetesͰͨͬͨॠؒʹDatadogͰϞχλϦϯά

Slide 41

Slide 41 text

from https://getkong.org/ ͍ΖΜͳAPIΛ౷߹؅ཧ Auth, Logging, Rate Limit
 ͳͲΛҰׅରԠ API Gateway Pattern by Kong

Slide 42

Slide 42 text

Google APIs ΋ API Gateway Pattern

Slide 43

Slide 43 text

·ͱΊ ϚΠΫϩαʔϏεԽͷखॱ 1. APIͷՁ஋Λ͋͛Δ • ԿͰ΋API͔ΒRender͢ΔΑ͏ʹ͢Δ 2. ͍͍APIΛ࡞ΕΔΑ͏ʹ͢Δ • Heroku΍େख͔ΒϕετϓϥΫςΟεΛֶͿ 3. APIΛ࡞Γ΍͘͢ • Auto Generator Ͱ࡞੒ͷ؆ུԽͱΫΦϦςΟ୲อ • API Gateway Pattern Ͱ౷Ұ؅ཧ • Docker + Kubernetes Ͱ؆୯ʹ্ཱͪ͛

Slide 44

Slide 44 text

͜ͷଓ͖ɺҰॹʹ΍Γ·ͤΜ͔ʁ

Slide 45

Slide 45 text

5IBOLZPV /BPZPTIJ"JLBXB !BXBLJB