Slide 1

Slide 1 text

)JHI1FSGPSNBODF 'BTU"1* *LVP4VZBNB

Slide 2

Slide 2 text

ಃࢁҭஉ*LVP4VZBNB !NBSUJO@MPWFS@TF 4NBSU/FXT *OD ✤"ET#BDLFOE&OHJOFFS ✤Πϯλʔωοτ޿ࠂ͕ઐ໳ ✤zࡾ౓ͷ൧ΑΓ޿ࠂ͕޷͖z ✤+7.࢖͍ 1ZUIPOྺ೥͘Β͍ ✤͓खॊΒ͔ʹʜ🙇

Slide 3

Slide 3 text

͜ͷηογϣϯ͔ΒಘΒΕΔ͜ͱ ✤ ϓϩϑΝΠϦϯάख๏ͱϘτϧωοΫͷಛఆ ✤զʑͷ؀ڥͰൃੜͨ͠۩ମతͳ՝୊ͱͦͷରࡦ 1ZUIPO8FC"QQMJDBUJPO ύϑΥʔϚϯενϡʔχϯάͷ۩ମతͳख๏

Slide 4

Slide 4 text

λΠτϧ͔Β෼͔ΔΑ͏ʹ ͜ͷຊʹ େม͓ੈ࿩ʹͳΓ·ͨ͠🙇

Slide 5

Slide 5 text

*OUSPEVDUJPO ෛՙςετͱϓϩϑΝΠϦϯά ௚໘ͨ͠՝୊ͱରࡦ ·ͱΊ "HFOEB

Slide 6

Slide 6 text

*OUSPEVDUJPO ෛՙςετͱϓϩϑΝΠϦϯά ௚໘ͨ͠՝୊ͱରࡦ ·ͱΊ "HFOEB

Slide 7

Slide 7 text

"CPVU4NBSU/FXT ݄ؒ 2,000ສਓ ɹɹɹར༻ऀ਺ 1೔໿16.7෼ར༻ ※2 1ਓ͋ͨΓ ʢ2019೥8݄ ೔ถ߹ࢉʣ No.1 χϡʔεΞϓϦ
 Ϣʔβʔ਺※1 ੜ׆ऀͷʮຖ೔ͷश׳ʯ
 ೔ຊ࠷େͷχϡʔεΞϓϦ ※1. Nielsen Mobile NetView 2021೥1݄࣌఺ ʢεϚʔτχϡʔεͷར༻ऀ਺ΛΞϓϦέʔγϣϯϨϕϧͰूܭʣ ※2. ࣗࣾ਺஋2021೥1݄ฏۉ

Slide 8

Slide 8 text

1ZUIPOJO4NBSU/FXT$PVQPO$IBOOFM OFXTTFSWJDF DPVQPOTFSWJDF BQJHBUFXBZ DPVQPOBENJO 3FEJT 3%# 8FCαʔόʔʹ'BTU"1*Λ࠾༻

Slide 9

Slide 9 text

• 'MBTLMJLFͳΞϊςʔγϣϯϕʔεͷϧʔςΟϯά"1* • 0QFO"1*ରԠ • ؆қతͳ%*ػೳ • ֮͑Δ͜ͱ͕গͳ͘ɺૉૣ͘։ൃΛ্ཱͪ͛ΒΕΔ l'BTU"1*͸ɺ1ZUIPOͷඪ४Ͱ͋Δܕώϯτʹج͍ͮͯ 1ZUIPOҎ߱Ͱ"1*Λߏங͢ΔͨΊͷɺ ϞμϯͰɺߴ଎ ߴύϑΥʔϚϯε ͳɺ8FCϑϨʔϜϫʔΫͰ͢ɻz Š'BTU"1* αʔϏεͷਝ଎ͳ্ཱͪ͛Λ࣮ݱʂ

Slide 10

Slide 10 text

'BTU"1*ඦฉ͸Ұߦʹ೗͔ͣ

Slide 11

Slide 11 text

1IBTFE3PMMPVUʜ OFXTTFSWJDF DPVQPOTFSWJDF BQJHBUFXBZ DPVQPOBENJO 3FEJT 3%#

Slide 12

Slide 12 text

'VMMZ3PMMPVU OFXTTFSWJDF DPVQPOTFSWJDF BQJHBUFXBZ DPVQPOBENJO 3FEJT 3%# εϚχϡʔͷશྗʂʂ

Slide 13

Slide 13 text

'VMMZ3PMMPVU OFXTTFSWJDF DPVQPOTFSWJDF BQJHBUFXBZ DPVQPOBENJO 3FEJT 3%# εϚχϡʔͷશྗʂʂ 🔥 🔥 🔥 🔥

Slide 14

Slide 14 text

'VMMZ3PMMPVU OFXTTFSWJDF DPVQPOTFSWJDF BQJHBUFXBZ DPVQPOBENJO 3FEJT 3%# εϚχϡʔͷશྗʂʂ 🔥 🔥 🔥 🔥 ύϑΥʔϚϯενϡʔχϯάͷཱྀ΁ʜ

Slide 15

Slide 15 text

*OUSPEVDUJPO ෛՙςετͱϓϩϑΝΠϦϯά ௚໘ͨ͠՝୊ͱରࡦ ·ͱΊ "HFOEB

Slide 16

Slide 16 text

ύϑΥʔϚϯενϡʔχϯάͷ৺ಘ ̍ɽੑೳ໨ඪΛܾΊΔ ̎ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ ̏ɽϘτϧωοΫΛղফ͢Δ ੑೳ໨ඪΛୡ੒ͨ͠ʁ &/%🎉 :&4 /0

Slide 17

Slide 17 text

8FC"QQMJDBUJPOʹ͓͚Δʮੑೳʯ ໨ඪ͕ͳ͍ͱແݶʹ΍Γଓ͚ͯ͠·͏ʂ εϧʔϓοτ ୯Ґ࣌ؒʹͲΕ͘Β͍ͨ͘͞Μ ϦΫΤετΛ͞͹͚Δ͔ʁ ? ָ͗͢͠ΔͷͰ ϨΠςϯγ ̍ͭͷϦΫΤετʹ ͲΕ͘Β͍͕͔͔࣌ؒΔ͔ʁ ɽੑೳ໨ඪΛܾΊΔ

Slide 18

Slide 18 text

-ʜฏۉ଴ͪϓϩηε਺ Еʜ ୯Ґ࣌ؒ͋ͨΓ ౸ண਺ 8ʜฏۉ଺ࡏ࣌ؒ 8FC"QQMJDBUJPOੑೳͷ࿩ʹஔ͖׵͑Δͱʜ WIP(Parallerism) = Throughput × Latency L = λW Ϧτϧͷ๏ଇ ɽੑೳ໨ඪΛܾΊΔ

Slide 19

Slide 19 text

ྫɿ SQTͷγεςϜΛDPSFͰࡹ͖͍ͨ ɹDPSFͷΠϯελϯε ͋Δ͍͸1PET Λ୆ฒ΂Δͱͯ͠ ̍୆͋ͨΓSQTࡹ͚͹ྑ͍ͷͰ ͭ·Γ̍Πϯελϯεͷੑೳ໨ඪΛ εϧʔϓοτSQT Ҏ্ ɺϨΠςϯγNT ҎԼ ɺͱઃఆ͢Δ 5(WIP)/100rps = 0.05s = 50ms ஫ɿ࣮ࡍʹ͸$16Λ࢖͍͖ΕΔΘ͚Ͱ͸ͳ͍͠ɺ*0΍$PODVSSFODZ΋͋Δ͠ɺ ,Tͷ1PEͰ͸ར༻Ͱ͖Δ$16ίΞ਺ͱMJNJU͕Ұக͠ͳ͍͠ɺ ʜͳͲͳͲͳͲ΋ͬͱ࿩͸ෳࡶͰ͕͢ɺେମͷ໨҆ͱͯ͠ ੑೳ໨ඪͷܾΊํɿྫ ɽੑೳ໨ඪΛܾΊΔ

Slide 20

Slide 20 text

ϧʔϧϓϩάϥϜ͕Ͳ͜Ͱ࣌ؒΛফඅ͢Δ͜ͱʹͳΔ͔஌Δ͜ͱ͸Ͱ͖ͳ͍ɻ ϘτϧωοΫ͸ڻ͘΂͖ՕॴͰى͜Δ΋ͷͰ͋Δɻ ͕ͨͬͯ͠ɺͲ͕͜ϘτϧωοΫͳͷ͔Λ͸͖ͬΓͤ͞Δ·Ͱ͸ɺ ਪଌΛߦͬͨΓɺεϐʔυϋοΫΛͯ͠͸ͳΒͳ͍ɻ ϧʔϧܭଌ͢΂͠ɻܭଌ͢Δ·Ͱ͸଎౓ͷͨΊͷௐ੔Λͯ͠͸ͳΒͳ͍ɻ ίʔυͷҰ෦͕࢒ΓΛѹ౗͠ͳ͍ͷͰ͋Ε͹ɺͳ͓͞ΒͰ͋Δɻ Š3PC1JLF/PUFTPO1SPHSBNNJOHJO$ Š<8JLJQFEJB>ύΠΫ$ϓϩάϥϛϯάʹؔ͢Δ֮͑ॻ͖ ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ ϘτϧωοΫҎ֎͸νϡʔχϯάͯ͠΋ແବແବ ਪଌ͢ΔͳܭଌͤΑ ܭଌͤͣϘτϧωοΫΛ஌Δ͜ͱ͸Ͱ͖ͳ͍͠ɺ

Slide 21

Slide 21 text

̍ɽੑೳ໨ඪΛܾΊΔ ̎ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ ̏ɽϘτϧωοΫΛղফ͢Δ ੑೳ໨ඪΛୡ੒ͨ͠ʁ &/%🎉 :&4 /0 ෛՙΛ͔͚ͯ 4ZTUFNશମͷෛՙঢ়گΛ֬ೝ "QQMJDBUJPOͷෛՙঢ়گΛ֬ೝ -PDBMͰͰ͖ΔݶΓಉ͡ঢ়گΛ࠶ݱ͠ɺ ෛՙΛ͔͚ͭͭܭଌ ϘτϧωοΫͷ ࠷΋ٙΘ͍͠ՕॴΛ௚͢ ϘτϧωοΫ͕ղফ͞Ε͔ͨʁ ੑೳ͕޲্͔ͨ͠ʁ ෛՙࢼݧ؀ڥʹ σϓϩΠͯ͠ܭଌ ϘτϧωοΫ͸ "QQMJDBUJPO ෛՙࢼݧʹར༻Ͱ͖Δ ؀ڥΛ४උ͢Δ ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ "QQMJDBUJPO͕ ϘτϧωοΫʹͳΔ·Ͱमਖ਼ :&4 /0 :&4 /0 ܭଌͷखॱͱπʔϧͨͪ Datadog APM • fastapi_profiler • py-spy ϑΟʔυόοΫϧʔϓΛ ૣ͍ͨ͘͠

Slide 22

Slide 22 text

• 1ZUIPO੡ͷ͍ΘΏΔϕϯνϚʔΫɾෛՙࢼݧπʔϧ • 1ZUIPO"1*ͰγφϦΦΛهड़ • γϯϓϧ͔ͭඞཁे෼ͳઃఆ • ΫϥελԽͯ͠େ͖ͳෛՙʹ΋ରԠ -PDVTUJTBOFBTZUPVTF TDSJQUBCMFBOE TDBMBCMFQFSGPSNBODFUFTUJOHUPPM Š-0$645 ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ ෛՙΛ͔͚Δɿ-0$645

Slide 23

Slide 23 text

ෛՙΛ͔͚Δɿ-0$645 ಉ࣌઀ଓ਺Λࢦఆ rps,median/95% tile latencyΛάϥϑԽ ಉ࣌઀ଓ਺Λ૿΍͠ͳ͕ΒϨΠςϯγ͕ѱԽ͢Δݶք·ͰෛՙΛ͔͚ɺ ࠷େεϧʔϓοτͱͦͷ࣌ͷϨΠςϯγΛ֬ೝ ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ

Slide 24

Slide 24 text

• ෛՙΛ͔͚ͨঢ়ଶͰͷγεςϜશମͷϦιʔεঢ়گΛ֬ೝ • 2ΞϓϦέʔγϣϯ͕ϘτϧωοΫʹͳ͍ͬͯΔ͔ʁ • ϘτϧωοΫ͕ΞϓϦέʔγϣϯʹҠΔ·Ͱ͸ɺΞϓϦέʔγϣϯͷνϡʔχϯά Λͯ͠΋ແବແବ • ͍͍ͩͨ%BUBCBTFͳͲͷϛυϧ΢ΣΞ͕ઌʹϘτϧωοΫʹͳΔ • 6QTUSFBNͷαʔϏε΍઀ଓ͢Δϛυϧ΢ΣΞ౳ͷϦιʔεʹ༨༟͕͋Δ͕ɺΞϓ Ϧέʔγϣϯͷεϧʔϓοτ্͕͕Βͳ͍ঢ়ଶ·Ͱνϡʔχϯά • ΞϓϦέʔγϣϯҎ֎ͷνϡʔχϯά͸ࠓճ͸ׂѪ🙇 γεςϜશମͷෛՙঢ়گΛ֬ೝɿ%BUBEPH Ҏޙͷ࿩͸ΞϓϦέʔγϣϯ͕ϘτϧωοΫͰ͋Δલఏ ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ

Slide 25

Slide 25 text

αʔϏεຖͷϦΫΤετ਺΍ CPU/MemoryͳͲͷར༻ঢ়گΛ֬ೝ ϛυϧ΢ΣΞͷCPU Usage ΍ ίωΫγϣϯ਺ͷมԽΛ֬ೝ ࡉ͔͍ঢ়گ͸ίϯςφʹBUUBDIͯ֬͠ೝͨ͠Γ΋͢Δ͕ɺ શମͷ܏޲Λ௫Ήͷʹେมศར ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ

Slide 26

Slide 26 text

• ηοτΞοϓ؆୯ɺαΠυΧʔͱ਺ߦͷىಈίʔυ • ࣮ࡍʹՔಇ͍ͯ͠Δ؀ڥͰͷσʔλ͕खʹೖΔ • ඞཁͳ৘ใ͸େମἧ͓ͬͯΓɺϘτϧωοΫͷൃݟʹ໾ཱͭ ΞϓϦέʔγϣϯܭଌᶃɿ%BUBEPH"1. %BUBEPH"1.ͱ$POUJOVPVT1SPGJMFS͸ɺ8FCαʔϏεɺΩϡʔɺσʔλϕʔε͕ ϦΫΤετɺΤϥʔɺϨΠςϯγʔΛ؂ࢹ͢ΔͨΊͷඪ४ͷύϑΥʔϚϯεμογϡ ϘʔυΛ࢖༻ͯ͠ɺΞϓϦέʔγϣϯΛৄࡉʹՄࢹԽ͠·͢ɻ Š%BUBEPH"1. ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ

Slide 27

Slide 27 text

ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ ෛՙ؀ڥΞϓϦέʔγϣϯܭଌɿ%BUBEPH"1. Latency histgram CPU time by scripts CPU time by function ͍͕ͭ͜Ұ൪࣌ؒΛ࢖͓ͬͯΓɺ ϘτϧωοΫީิ ͕ͩߴ͍💸ɺಛఆͷΠϯελϯεͷΈʹదԠ͢ΔͳͲͷ޻෉Λʜ

Slide 28

Slide 28 text

-PDBMΞϓϦέʔγϣϯܭଌᶃɿGBTUBQJ@QSPGJMFS ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ "'BTU"1*.JEEMFXBSFPGQZJOTUSVNFOUUP DIFDLZPVSTFSWJDFDPEFQFSGPSNBODF ŠGBTUBQJ@QSPGJMFS • 'BTU"1*ϛυϧ΢ΣΞͱͯ͠QZJOTUSVNFOUΛ౷߹ • ϩʔΧϧͰίʔυΛमਖ਼ͭͭ͠ɺ$16࣌ؒΛܭଌ͢Δͱ͖ʹศར • ύϑΥʔϚϯεӨڹ͕େ͖͍ͨΊɺຊ൪΍ෛՙঢ়گԼͰ͸࢖͑ͳ͍

Slide 29

Slide 29 text

-PDBMΞϓϦέʔγϣϯܭଌᶃɿGBTUBQJ@QSPGJMFS ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ add_middleware ͢Δ͚ͩͰOK sortϝιου͕ ஗͍ʹϘτϧωοΫީิ

Slide 30

Slide 30 text

• 3VTU੡ͷϓϩϑΝΠϥɺ௒௿Φʔόʔϔου • ϩʔΧϧ؀ڥෛՙ؀ڥͰͬ͞ͱ$16Λܭଌ͍ͨ͠ͱ͖ʹศར • (*-΍ϚϧνεϨουॲཧͷϘτϧωοΫ͕ٙΘ͍͠ͱ͖ʹ΋ศར • GBTUBQJ@QSPGJMFS͸GBTUBQJ؅ཧԼʹͳ͍εϨουΛܭଌͰ͖ͳ͍ʜ -PDBMΞϓϦέʔγϣϯܭଌᶄɿQZTQZ ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ *UMFUTZPVWJTVBMJ[FXIBUZPVS1ZUIPOQSPHSBN JTTQFOEJOHUJNFPOXJUIPVUSFTUBSUJOHUIF QSPHSBNPSNPEJGZJOHUIFDPEFJOBOZXBZ ŠQZTQZ

Slide 31

Slide 31 text

͜ͷϝιου͕ΤϯυϙΠϯτ ॲཧͷຆͲͷ࣌ؒΛ઎Ί͍ͯΔ ɽܭଌɾϘτϧωοΫΛಛఆ͢Δ -PDBMΞϓϦέʔγϣϯܭଌᶄɿQZTQZ

Slide 32

Slide 32 text

*OUSPEVDUJPO ෛՙςετͱϓϩϑΝΠϦϯά ௚໘ͨ͠՝୊ͱରࡦ ·ͱΊ "HFOEB

Slide 33

Slide 33 text

'BTU"1*ͷσϓϩΠ࣌ߏ੒ͱෛՙಛੑ (VOJDPSOTVQQPSUTXPSLJOHBTBQSPDFTTNBOBHFSBOEBMMPXJOHVTFSTUPUFMMJUXIJDITQFDJGJDXPSLFS QSPDFTTDMBTTUPVTF5IFO(VOJDPSOXPVMETUBSUPOFPSNPSFXPSLFSQSPDFTTFTVTJOHUIBUDMBTT "OE6WJDPSOIBTB(VOJDPSODPNQBUJCMFXPSLFSDMBTT Š4FSWFS8PSLFST(VOJDPSOXJUI6WJDPSO ϓϩηεͷىಈͱGPSL TPDLFUΛXPSLFSʹ౉͢ ϦΫΤετϨεϙϯε ඇಉظॲཧ Request Response Func call callback Extends Worker ΞϓϦέʔγϣϯ ϏδωεϩδοΫ

Slide 34

Slide 34 text

'BTU"1*ͷσϓϩΠ࣌ߏ੒ͱෛՙಛੑ (VOJDPSOTVQQPSUTXPSLJOHBTBQSPDFTTNBOBHFSBOEBMMPXJOHVTFSTUPUFMMJUXIJDITQFDJGJDXPSLFS QSPDFTTDMBTTUPVTF5IFO(VOJDPSOXPVMETUBSUPOFPSNPSFXPSLFSQSPDFTTFTVTJOHUIBUDMBTT "OE6WJDPSOIBTB(VOJDPSODPNQBUJCMFXPSLFSDMBTT Š4FSWFS8PSLFST(VOJDPSOXJUI6WJDPSO Request Response Func call callback Extends Worker ϓϩηε؅ཧͷΈͳͷͰ ύϑΥʔϚϯεӨڹͳ͠ 4UBSMFUUFΑΓ͸ૣ ͘ͳΒͳ͍͕ 1ZUIPO"4(*ք ࠷଎ 4UBSMFUUFΑΓԼ͕ϘτϧωοΫʹͳΔ͜ͱ͸ࠓճ͸ͳ͔ͬͨ

Slide 35

Slide 35 text

*0CPVOEͳॲཧ͕஗͍ $16CPVOEͳॲཧ͕஗͍ .VMUJ5ISFBE͕஗͍ ॲཧܥͷมߋʹΑΔશମతͳੑೳ޲্ ̏ɽ௚໘ͨ͠՝୊

Slide 36

Slide 36 text

*0CPVOEͳॲཧ͕஗͍ ✤ ௚໘ͨ͠՝୊ 3FEJTͷSFBEΞΫηε͕஗͍ ✤ ঱ঢ় • $16Λ࢖͍੾ͬͯͳ͍ͷʹεϧʔϓοτ্͕͕Βͳ͍ • UPQ WNTUBU౳ͰDQVVTΛ֬ೝ ✤ ݪҼ • %#ΞΫηεͳͲɺωοτϫʔΫ*0Λཁ͢Δॲཧ • ϑΝΠϧॻ͖ࠐΈ

Slide 37

Slide 37 text

• ωοτϫʔΫ͕བྷΉͱ͜Ζ͸BTZODBXBJUΛ࢖͏ • ରԠϥΠϒϥϦ΋ଟ͍ • FHBJPSFEJTIUUQYʜ *0CPVOE3FEJTΞΫηε͕஗͍ ରࡦᶃɿBDZODJPΛ࢖͏ BTZODJP͸BTZODBXBJUߏจΛ࢖͍ฒߦॲཧͷ ίʔυΛॻͨ͘ΊͷϥΠϒϥϦͰ͢ɻ ŠBTZODJP

Slide 38

Slide 38 text

ରࡦᶃɿBDZODJPΛ࢖͏ fastAPIͰ͸ϧʔςΟϯά ϝιουΛasyncʹ͢Δ͚ͩ async method ͷ಺෦Ͱawait *0CPVOE3FEJTΞΫηε͕஗͍

Slide 39

Slide 39 text

• ͦΕͰ΋ωοτϫʔΫ͕བྷΉͱ͜Ζ͸جຊతʹΊͪΌ஗͍ • ϝϞϦࢀরͱൺ΂Δͱdഒ͕͔͔ۙ࣌ؒ͘Δ • ݁Ռ੔߹ੑͷڐ༰౓͕ߴ͍৔߹ɺΞϓϦέʔγϣϯϝϞϦʹऔ ಘͨ݁͠ՌΛΩϟογϡ͢Δ ରࡦᶄɿDBDIF͢Δ Latency Comparison Numbers (~2012) ---------------------------------- : Main memory reference 100 ns : Round trip within same datacenter 500,000 ns 500 us — Latency Numbers Every Programmer Should Know *0CPVOE3FEJTΞΫηε͕஗͍

Slide 40

Slide 40 text

3FEJTΞΫηε͕஗͍ʜରࡦᶄɿDBDIF͢Δ OrderedDictΛར༻ͨ͠ ؆қͳLRUCache Cache͕ͳ͔ͬͨ৔߹ͷΈ RedisʹΞΫηε method͝ͱΩϟγϡͯ͘͠ΕΔ lru_cacheΞϊςʔγϣϯ΋ศར *0CPVOE3FEJTΞΫηε͕஗͍

Slide 41

Slide 41 text

✤ ௚໘ͨ͠՝୊ 63-Τϯίʔυॲཧ͕஗͍ Ґஔ৘ใͷHFPIBTIͷܭࢉ͕஗͍ Ґஔ৘ใ͔Βͷڑ཭ͷܭࢉ͕஗͍ ✤ ঱ঢ় • UPQ WNTUBU౳ͰVTFSUJNF͕ுΓ෇͘ɺ-"͕ߴ͍ • LT؀ڥͰ͋Ε͹5ISPUUMF͞ΕΔ ✤ ओͳݪҼ • ුಈখ਺఺ܭࢉͳͲγϯϓϧʹॏ͍ܭࢉ • ඇޮ཰ͳΞϧΰϦζϜ $16CPVOEͳॲཧ͕஗͍

Slide 42

Slide 42 text

ରࡦɿࣄલܭࢉDBDIF͢Δ τϥϯβΫγϣϯ͝ͱʹ݁Ռ͕มΘΒͳ͍΋ͷ͸ ΦϑϥΠϯͰࣄલʹܭࢉ͓͔ͯ͘͠ɺ ܭࢉ݁ՌΛDBDIF͢Δ͜ͱͰॏ͍ܭࢉࣗମΛόΠύε͢Δ urllib/parse.py Ͱଟ͘ͷ࣌ؒΛ࢖͍ͬͯΔ Urlͷܭࢉ݁ՌΛ Cache͢Δ $16CPVOE63-Τϯίʔυॲཧ

Slide 43

Slide 43 text

• ϦΫΤετ͝ͱʹΦϯϥΠϯͰܭࢉ͠ͳ͚Ε͹ͳΒͣɺ͔ͭܭࢉෛՙͷ ߴ͍΋ͷ • (FPIBTIʜҐஔ৘ใ MBUMPO ΛಛఆͷྖҬ͝ͱʹIBTIԽ͢Δ • $ݴޠͳͲͷ௿ਫ४ݴޠʹ༧ΊίϯύΠϧͯ͠͠·͏ • ؔ਺͝ͱͳͲɺ෦෼తʹదԠ͢Δ͜ͱ͕Մೳ ରࡦɿ$ZUIPO $ZUIPOJTBOPQUJNJTJOHTUBUJDDPNQJMFSGPSCPUIUIF1ZUIPO QSPHSBNNJOHMBOHVBHFBOEUIFFYUFOEFE$ZUIPO QSPHSBNNJOHMBOHVBHF Š$ZUIPO $16CPVOEHFPIBTIͷܭࢉ͕஗͍

Slide 44

Slide 44 text

ࢦఆ͞ΕͨҐஔ৘ใ͔Β geohash(maptile)Λܭࢉ͢Δؔ਺ .pyxʹॻ͍ͯίϯύΠϧ͢Δ ݺͼग़͠ଆ͸௨ৗͷPythonͱಉ͡ ͜Μͳײ͡ͷ setup.pyΛ४උͯ͠ docker build͢Δͱ͖ʹ ίϯύΠϧ͍ͯ͠Δ ରࡦɿ$ZUIPO $16CPVOEHFPIBTIͷܭࢉ͕஗͍

Slide 45

Slide 45 text

• ϦΫΤετͷҐஔ৘ใͱɺۙ͘ͷΫʔϙϯͱͷڑ཭ͷܭࢉ • ۙ͘ʹ͋ΔΫʔϙϯͷ਺͚ͩϧʔϓͯ͠ܭࢉ͍ͯͨ͠ • ϧʔϓॲཧΛɺOVNQZͷϕΫτϧܭࢉΛ༻͍ͯ$16DBDIFͷར༻Λ࠷దԽ͢Δ • $16$BDIF͔Βͷϩʔυ͸3".ΑΓ΋ང͔ʹߴ଎ ରࡦɿOVNQZ $16CPVOEڑ཭ͷܭࢉ͕஗͍ Latency Comparison Numbers (~2012) ---------------------------------- L1 cache reference 0.5 ns L2 cache reference 7 ns 14x L1 cache : Main memory reference 100 ns 20x L2 cache, 200x L1 cache — Latency Numbers Every Programmer Should Know

Slide 46

Slide 46 text

ϕΫτϧԽͯ͠ɺ Ҏޙͷܭࢉ͸ϕΫτϧܭࢉ ϦΫΤετͷҐஔ৘ใͱͦΕͧΕͷ Ϋʔϙϯͷڑ཭Λ ΦϯϥΠϯͰܭࢉ͍ͨ͠ ରࡦɿOVNQZ $16CPVOEڑ཭ͷܭࢉ͕஗͍

Slide 47

Slide 47 text

.VMUJ5ISFBE͕஗͍ ✤ ௚໘ͨ͠՝୊ -PHHJOH͕஗͍ ✤ ঱ঢ় • 'BTU"1*Ҏ֎ͷ5ISFBEͰ$16Λ࢖͍ͬͯΔ • %BUBEPH"1.Ͱ֬ೝ • QZTQZUPQͰ(*-ͷ஋͕௿͍ ✤ ݪҼ • ࠓճ͸MPHSVͱ͍͏ϥΠϒϥϦ͕.VMUJ5ISFBEͰϩάΛॻ͍͍ͯͯɺͦ ͜ʹ͕͔͔͍࣌ؒͬͯͨ • 1ZUIPO͸5ISFBEΛѻ͑Δ͕ɺ(*-͕͋ΔͨΊޮ཰͕ѱ͍

Slide 48

Slide 48 text

.VMUJ5ISFBE͕஗͍ *O$1ZUIPO UIFHMPCBMJOUFSQSFUFSMPDL PS(*- JTBNVUFY UIBUQSPUFDUTBDDFTTUP1ZUIPOPCKFDUT QSFWFOUJOHNVMUJQMF UISFBETGSPNFYFDVUJOH1ZUIPOCZUFDPEFTBUPODF Š(MPCBM*OUFSQSFUFS-PDL (*-(MPCBM*OUFSQSFUFS-PDL • 5ISFBEΛཱͯͯ΋ಉ࣌ʹ࣮ߦ͞ΕΔͷ͸ϓϩηε಺Ͱ̍ͭ • 1ZUIPOͰ͸ฒྻॲཧ͸.VJUM1SPDFTTJOH ͜Εʹฒߦॲཧ BTZODJPΛ૊Έ߹Θͤͯରॲ͢Δ

Slide 49

Slide 49 text

.VMUJ5ISFBE͕஗͍ Log৘ใͷγϦΞϥΠζͱ emmitʹ͕͔͔͍࣌ؒͬͯΔ Queue͔Βऔಘͯ͠σγ ϦΞϥΠζ͍ͯ͠Δ໛༷ _enqueue͕true(default) ͩͱɺSimpleQueueͱlogग़ྗ༻ ͷThreadΛͨͯΔ multiprocessing.SimpleQueue ͷ࣮ମ͸Processؒ௨৴ͷPipe 8SJUFS5ISFBEͱͷσʔλड͚౉͕͠஗ͦ͏

Slide 50

Slide 50 text

.VMUJ5ISFBE-PHHJOH͕஗͍ ରࡦɿϩΪϯάͷ཈੍ͱϥΠϒϥϦͷมߋ w GBTUMPHHJOHʹ৐Γ׵͑ͨ w ͦͦ͜͜༰ྔͷେ͖͍MPHΛు͖͍͕ͨɺະղܾ

Slide 51

Slide 51 text

• ීஈ࢖͍ͬͯΔ$1ZUIPOҎ֎ʹ΋༷ʑͳॲཧܥ͕͋Δ • ௿ڃݴޠʹίϯύΠϧ͢Δ΋ͷɺ+*5ίϯύΠϥΛ࣋ͭ΋ͷɺFUDʜ • ࠓճ͸ͭΛࢼͯ͠ɺ1Z1ZΛ࠾༻ͨ͠ DJOEFS 1Z1Z • $16͕ϘτϧωοΫͰ͋Ε͹ɺશମతͳੑೳ޲্͕ظ଴Ͱ͖Δ ॲཧܥͷมߋʹΑΔશମతͳੑೳ޲্

Slide 52

Slide 52 text

ॲཧܥͷมߋDJOEFS $JOEFSJT*OTUBHSBNTJOUFSOBMQFSGPSNBODFPSJFOUFEQSPEVDUJPO WFSTJPOPG$1ZUIPO *UDPOUBJOTBOVNCFSPGQFSGPSNBODFPQUJNJ[BUJPOT JODMVEJOH CZUFDPEFJOMJOFDBDIJOH FBHFSFWBMVBUJPOPGDPSPVUJOFT ʜ ŠDJOEFS • 'BDFCPPLۘ੡ͷύϑΥʔϚϯεվળ͞Εͨ$1ZUIPO • զʑͷ؀ڥͰ͸ɺఔ౓ͷੑೳ޲্͕ݟΒΕͨ • $1ZUIPOͱͷޓ׵ੑ͕ߴ͘ɺϥΠϒϥϦ΋΄ͱΜͲ࢖͑Δ • ͕ɺࣗલͰϏϧυ͢Δඞཁ͕͋ͬͨΓ(JU)VC΋׆ൃͰͳ͔ͬͨΓυΩϡϝϯτ͕օແͩͬͨ Γͱɺӡ༻໘ͰͭΒ͘அ೦

Slide 53

Slide 53 text

ॲཧܥͷมߋ1Z1Z "GBTU DPNQMJBOUBMUFSOBUJWFJNQMFNFOUBUJPOPG1ZUIPO 0OBWFSBHF 1Z1ZJTUJNFTGBTUFS UIBO$1ZUIPO Š1Z1Z • +*5ίϯύΠϥ*ODNJOJNBSL($ • $1ZUIPOͱͷޓ׵ੑ΋͔ͳΓߴ͍ • ΋ͪΖΜσϝϦοτ΋ͦΕͳΓʹ͋Δ • ͕ɺੑೳ໘ͰͷϝϦοτ͕େ͖͔ͬͨͨΊɺݱࡏຊ൪Քಇத • ͍ۙੑೳ޲্Λ֬ೝ

Slide 54

Slide 54 text

ۜͷ஄ؙͰ͸ͳ͍ ✤ ࡌͤସ͑ɾӡ༻ʹ͋ͨͬͯ௚໘ͨ͠՝୊ ࠷৽൛͕1ZUIPO Ұ෦ͷϥΠϒϥϦ͕࢖͑ͳ͍ ($0QUJPOࢦఆ࿙ΕͰ00.ࢮ 'BTU"1*ͱͷ૊Έ߹ΘͤͰϝϞϦϦʔΫʁ ॲཧܥͷมߋ1Z1Z

Slide 55

Slide 55 text

՝୊ᶃɿ࠷৽൛͕1ZUIPO ✤ ՝୊ɿݱࡏͷ࠷৽൛͕1ZUIPO • CFUB DPNNJOHTPPO ✤ ରԠ • ϕʔεͰ։ൃ͍ͯͨ͠ͷͰɺҰ෦ͷՕॴΛμ΢ϯάϨʔυ • ηΠ΢νԋࢉࢠ:= • Ґஔઐ༻Ҿ਺def huga(hoge, /, …) • ࣮࣭͋Μ·Γࠔ͍ͬͯͳ͍ ॲཧܥͷมߋ1Z1Z

Slide 56

Slide 56 text

՝୊ᶄɿҰ෦ͷϥΠϒϥϦ͕࢖͑ͳ͍ ✤ ՝୊ɿ1&1֎෦ιʔεͷϏϧυΛ൐͏ϥΠϒϥϦ͸΄΅/( • FH • PSKTPOʜSVTU੡ߴ଎+40/γϦΞϥΠβ😭 • EEUSBDFQZʜ%BUB%PH"1.ܭଌ༻😭 • GBTUBQJQSPGJMFSʜ͜͜·Ͱେ׆༂ͷϓϩϑΝΠϥ😭 • CMBDL DBVTFECZUZQFEBTU ʜ-JOUFS'PSNBUUFS QZTFOܦ༝Ͱར༻😭 ✤ ରԠ • ผͷϥΠϒϥϦΛ࢖͏ • ։ൃ؀ڥ༻ͱσϓϩΠ༻ͰผʑͷॲཧܥΛར༻͢Δ ॲཧܥͷมߋ1Z1Z

Slide 57

Slide 57 text

՝୊ᶄɿҰ෦ͷϥΠϒϥϦ͕࢖͑ͳ͍ $1ZUIPOͰ͸ಈ͕͘1Z1ZͰ͸ಈ͔ͳ͍ͱ͍ͬͨෆ۩߹Λճආ͢ΔͨΊɺ $%ͷࡍʹຊ൪༻ίϯςφΛ༻͍ͯFFςετΛ࣮ࢪ͍ͯ͠Δ ։ൃ༻ / CPython3.7 CI্ͰͷUT΋ͪ͜ΒͰ࣮ߦ ຊ൪༻ / PyPy3.7 ॲཧܥͷมߋ1Z1Z

Slide 58

Slide 58 text

՝୊ᶅɿ($0QUJPOࢦఆ࿙ΕͰ00.ࢮ ✤ ՝୊ɿϝϞϦ͕ϞϦϞϦ੒௕͠ɺ00.,JMMFSʹΑΓࢮ • 1Z1Zͷ($͸JODNJOJNBSL • ($0QUJPOͷઃఆ͕ඞཁ ✤ ରԠ • 1:1:@($@%(Λࢦఆͯ͠($-PHΛग़ྗ͢Δ • 1:1:@($@."9Λࢦఆͯ͠ώʔϓ্ݶ஋Λ੍ݶ͢Δ ॲཧܥͷมߋ1Z1Z

Slide 59

Slide 59 text

՝୊ᶅɿ($0QUJPOࢦఆ࿙ΕͰ00.ࢮ MaxWorker x PYPY_GC_MAX Λ֬อ ࠷௿ݶ PYPY_GC_MAX͸ࢦఆ ॲཧܥͷมߋ1Z1Z

Slide 60

Slide 60 text

՝୊ᶆɿ'BTU"1*ͱͷ૊Έ߹ΘͤͰϝϞϦϦʔΫʁ ✤ ՝୊ɿϝϞϦ͕ϞϦϞϦ੒௕͠ɺ00.,JMMFSͰࢮʢ̎ʣ • &DIPαʔόʔͰ΋ɺෛՙΛ͔͚ΔͱϝϞϦ͕୯ௐ૿Ճ͢Δ • Ϧόϓϩ͍ͯͨ͠OHJOYͰ,FFQ"MJWF͍ͯ͠ͳ͔ͬͨʜ ✤ ରԠ • )551઀ଓʢ%FGBVMU,FFQ"MJWFʣʹ͢Δͱղফͨ͠ • VWJDPSOͷUJNFPVULFFQBMJWF΋ઃఆ͓ͯ͘͠ • ͋·Γਂ௥͍͍ͯ͠ͳ͍͕ɺDPOOFDUJPOपΓͷ໰୊Ά͍ͷͰɺ 'BTU"1*ͱ͍͏ΑΓ͸VWJDPSOͷ໰୊͔ ॲཧܥͷมߋ1Z1Z

Slide 61

Slide 61 text

̏ɽ௚໘ͨ͠՝୊ <5ISPVHIQVU> SQT <UJMF-BUFODZ> NT <5ISPVHIQVU> SQT ‐ <UJMF-BUFODZ> NT ‐ ͢΂ͯରԠͨ͠ޙɺΠϯελϯεͰͷੑೳվળ

Slide 62

Slide 62 text

*OUSPEVDUJPO ෛՙςετͱϓϩϑΝΠϦϯά ௚໘ͨ͠՝୊ͱରࡦ ·ͱΊ "HFOEB

Slide 63

Slide 63 text

·ͱΊ ✤ ෛՙςετͱϓϩϑΝΠϦϯά • ໨ඪΛܾΊΔˠܭଌ͢ΔˠϘτϧωοΫʹରԠ͢Δ • ໾ཱͭπʔϧͨͪɿMPDVTU EBUBEPH GBTUBQJQSPGJMFS QZTQZ ✤ ՝୊ͱରԠ • *0CPVOEBTZODJP DBDIF • $16CPVOEDBDIF $ZUIPO OVNQZ • ॲཧܥͷมߋ1Z1Z

Slide 64

Slide 64 text

)JHI1FSGPSNBODFͳ 'BTU"1*-JGFΛ

Slide 65

Slide 65 text

Thank You for Your Kind Attention! UXJUUFS!NBSUJO@MPWFS@TF