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

インフラエンジニアが学んだ
Go言語での並行処理失敗パターン

nwiizo
November 16, 2021
1.6k

 インフラエンジニアが学んだ
Go言語での並行処理失敗パターン

2021/11/16 Infra Study 2nd #7「SREと組織」にて発表
https://forkwell.connpass.com/event/228038/

nwiizo

November 16, 2021
Tweet

Transcript

  1. ΠϯϑϥΤϯδχΞͷඇಉظॲཧ w ʹΑΔόοΫάϥϯυॲཧ w YBSHTʹΑΔฒྻ࣮ߦ time seq 10 | xargs

    -t -P1 -n1 'sleep' sleep 1 sleep 2 … ________________________________________________________ Executed in 55.11 secs fish external usr time 13.14 millis 0.19 millis 12.94 millis sys time 47.95 millis 2.26 millis 45.69 millis time seq 10 | xargs -t -P3 -n1 'sleep' sleep 1 sleep 2 … ________________________________________________________ Executed in 22.04 secs fish external usr time 10.70 millis 0.18 millis 10.52 millis sys time 33.78 millis 2.25 millis 31.53 millis w Ҿ਺ͷ෼͚ͩ4MFFQ͢ΔϫϯϥΠφʔΛ 
 ฒྻ਺Ͱ࣮ߦ͢Δ৔߹ ඵͰ׬ྃ ͱฒྻ਺Ͱ࣮ߦͨ͠৔߹ ඵͰ׬ྃ $ ίϚϯυ & [1] 4403 w ίϚϯυͷ࠷ޙʹΛ෇Ճ͢Δ͜ͱʹΑΓɺ 
 ͦͷίϚϯυΛόοΫάϥ΢ϯυͰಈ͔͢͜ͱ͕Ͱ͖Δɻ ແअؾʹ΍Δͱμϝ͕ͩίϯτϩʔϧՄೳ ແअؾʹGPSΛճ͢ͱΫϥΠΞϯτɺαʔόʔ ͞·͟·ͳ΋ͷ͕ࢮ͵ େ޷͖ͳγΣϧεΫϦϓτ
  2. ্͔Β࣮ߦ͞ΕΔͱ͍͏ࡨ֮ͰӬԕʹσόοά͕ऴΘΒͳ͍ w Ұମɺ͍͔ͭΒ্͔Β࣮ߦ͞ΕΔͱɻɻɻ w ιʔείʔυ͸্͔ΒԼʹ޲͔ͬͯॻ͍͍ͯ͘͜ͱ͕ଟ͍ͱ ࢥ͍·͢ɻ͜ͷ͜ͱ͔Βʮίʔυ͸্͔ΒԼʹॱ൪ʹ࣮ߦ͞ ΕΔͩΖ͏ʯͱ͍͏ࡨ֮ʹؕΓ͕ͪͰ͕͢ɺฒߦॲཧΛ͢ Δ৔߹ʹ͸͜ΕΒ͕࣮ߦ͞ΕΔ·Ͱ෼͔Βͳ͍ɻ 
 


    ͦͷͨΊɺຊ౰ʹ෼͔ΒͣʹͱΜͰ΋ͳ͍λΠϛϯάͰ 
 ࢥͬͯ΋ͳ͍ॲཧ͕࣮ߦ͞ΕΔ৔߹͕͋ΔͷͰ 
 ͜ͷࡨ֮͸ૣʑʹࣺͯڈ͙ͬͯ͢ʹ໨ͷલͷ 
 ϩάͱਅ伨ʹ޲͖߹͍·͠ΐ͏ʂ w ฒߦॲཧʹ͓͚Δ࣮ߦॱ൪ͷอূΛ΍͍ͬͯ͘ w εϦʔϓʹΑΔॱ൪อূ w ΞτϛοΫੑ w TZOD.VUFY 
  3. ͦΕ͸ɺෳ਺ͷϩδοΫΛڠௐͤ͞Α͏ͱͯ͠·͔͢ʁϚδʁ w ϩδοΫΛݟ௚ͨ͠ํ͕͍͍৔߹΋ଟ͋͘Δ w ͋ͳ͕ͨຊ౰ʹඞཁͳͷ͸ฒߦੑͷ͋ΔॲཧͰ͔͢ʁ w 3BDF$POEJUJPO ڝ߹ঢ়ଶ Λආ͚Δඞཁ͕͋Δ w

    ڞ༗ϝϞϦʹਖ਼͘͠ΞΫηε͠ͳ͍ͱ͍͚ͳ͍ w ষେن໛։ൃͰͷฒྻॲཧͳͲΛख़ಡ͢Δ͜ͱ͕ඞཁ 
 ɹෆ݈શͳΰϧʔνϯΛ௚͢ͳͲΊͪΌͪ͘Ό೉͍͠ w ඞཁͳͷ͸டংΛ࣋ͬͨඇಉظॲཧ͡ΌͶʁ w σόοάͷ࣌ʹSVOUJNF(0."9130$4 ΛߴΊͨΓͯ͠ 
 ڝ߹Λ֬ೝ͢Δ࡞ۀͱ͔ਖ਼௚ɺͨ͘͠ͳ͍ɻɻɻ w HPSPVUJOFͷ਺΍ಉظɺඇಉظʹ͍ͭͯ 
 ؀ڥม਺΍࣮૷Ͱ͓࣋ͬͯ͘ͱ౎߹͕ଟ͍͜ͱ͕͋Δ  O`reillyɹGoݴޠʹΑΔฒߦॲཧɹΑΓҾ༻
  4. ࣮ߦ࣌ͷෛՙ͸ͦͷ؀ڥͰͦͷλΠϛϯάͰ࣮ߦ͢Δ·Ͱ෼͔Βͳ͍ w ࣮ߦ͢Δ·Ͱ෼͔Βͳ͍ w ෛՙͷ͔͔ΔॲཧΛ੍ݶͳ͠ʹฒྻԽͯ͠΋ຊ౰ʹҙຯͳ ͘Ή͠Ζ֐ѱͰ͢ɻॲཧͷฒྻ਺Λ༧ଌՄೳͳ৔߹͸ɺͦ ΕΛ࣮ߦ͢Ε͹Α͍Ͱ͕͢ෆ໌֬ͳ৔߹ʹ΋ɺ$16ͷί Ξ਺͕౰ͨΓʹͳΔ͜ͱ͕͋Γ·͢ɻ 
 (PҎ߱ɺσϑΥϧτ஋͸ίΞͷ਺ʹͳΓ·͢ɻ

    
 ͦͷͨΊɺຊ൪؀ڥͱखݩͰ࣮ߦ͕࣌ؒมΘΔ͜ͱ͕͋Δ w ͪ͜ΒSVOUJNF(0."9130$4 SVOUJNF/VN$16 Λຊ൪Ͱ͢ͳ w ·ͨɺຊ൪ӡ༻தͷόονॲཧΛᢞΊ͔͔ͯΔͱ 
 λΠϛϯάʹΑͬͯ͸طʹ"1*΍%#ʹෛՙֻ͕͔ͬͯ Δɻଞͷόον͕૸ͬͯΔͳͲɻʰனؒʹखݩͷ؀ڥ͔Β ͸͏·͘ߦͬͨͷͰຊ൪Ͱ΋0,ͳͷͩʱͱؾܰʹߟ͑ͯ ͍Δͱͦͷ೔ͷ໷ʹढ͍ͷΦϯίʔϧ͕ݦݱ͢ΔΑ