Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Golang @ISUCON
Search
y_matsuwitter
November 30, 2014
Programming
10
4.2k
Golang @ISUCON
GoCon 2014 Autmun
y_matsuwitter
November 30, 2014
Tweet
Share
More Decks by y_matsuwitter
See All by y_matsuwitter
Product Utilization of Large Language Models Starting Today
ymatsuwitter
3
2.3k
経営・意思・エンジニアリング
ymatsuwitter
23
19k
LLM in 2023 and 2024
ymatsuwitter
8
5.4k
Turbulent Technological Changes and Career Strategies
ymatsuwitter
2
2.6k
LLM in toB Service and Its UX
ymatsuwitter
6
10k
Agent and small LLM validation
ymatsuwitter
7
2.9k
Information management for a culture of speed: The story of Notion and LayerX
ymatsuwitter
4
9.8k
Monorepo on AWS
ymatsuwitter
0
290
Tech behind LayerX SaaS products
ymatsuwitter
0
3.1k
Other Decks in Programming
See All in Programming
watsonx.ai Dojo #6 継続的なAIアプリ開発と展開
oniak3ibm
PRO
0
170
20241217 競争力強化とビジネス価値創出への挑戦:モノタロウのシステムモダナイズ、開発組織の進化と今後の展望
monotaro
PRO
0
280
GitHub CopilotでTypeScriptの コード生成するワザップ
starfish719
26
5.9k
Jaspr Dart Web Framework 박제창 @Devfest 2024
itsmedreamwalker
0
150
カンファレンス動画鑑賞会のススメ / Osaka.swift #1
hironytic
0
170
はてなにおけるfujiwara-wareの活用やecspressoのCI/CD構成 / Fujiwara Tech Conference 2025
cohalz
2
2.7k
Lookerは可視化だけじゃない。UIコンポーネントもあるんだ!
ymd65536
1
130
テストコード書いてみませんか?
onopon
2
340
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
1
290
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
400
EC2からECSへ 念願のコンテナ移行と巨大レガシーPHPアプリケーションの再構築
sumiyae
3
580
Flatt Security XSS Challenge 解答・解説
flatt_security
0
730
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Into the Great Unknown - MozCon
thekraken
34
1.6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3.1k
Mobile First: as difficult as doing things right
swwweet
222
9k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
The World Runs on Bad Software
bkeepers
PRO
66
11k
Optimizing for Happiness
mojombo
376
70k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Building an army of robots
kneath
302
45k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Making Projects Easy
brettharned
116
6k
Transcript
Golang @ISUCON y_matsuwitter
!Z@NBUTVXJUUFS Gunosy inc., ࣥߦһ ! Goྺ1ऑ͘Β͍ ! όϥϯεϘʔϧਖ਼࠲ͷਓ
ීஈͷۀ GoʹΑΔAPIαʔόߏங (2014.3~) iOS/AndroidͷΞϓϦ։ൃ Django/RailsʹΑΔWebApp։ൃ
ʊਓਓਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹGolangΤϯδχΞืूதɹʻ ʉY^Y^Y^Y^Y^Y^Y^Y^Y^Yʉ
ࠓͷ ॳΊͯͷISUCONΛGolangͰઓͬͯΈͨ ※GolangҎ֎ͷ͠·ͤΜ Ґͱத్ͳ݁ՌͰ͕ͨ͠ʜ
ISUCONͱ Iikanjini Speed Up CONtest ! 8࣌ؒͰ༩͑ΒΕͨWebAppΛग़དྷΔݶΓߴ Խ͢Δίϯςετ
༧બ αʔό: 1 େMySQLΛDB ࠓۜߦͷϩάΠϯϖʔδ͕ࡐͰͨ͠
ܾউ αʔό: 3~4 ը૾ॲཧಈըͷ৴ͳͲ͋Δఔෛՙͷߴ ͍ॲཧΛؚΉWebApp ࠓಈըࠂͷ৴αʔόͰͨ͠
ߴͳWebαʔόͷͨΊʹ ϦιʔεΛ͍Δ CPU … Encode/decode, ը૾ॲཧͳͲ Memory … ϓϩηε্ͷσʔλྔ Data
Transfer … αʔόؒɺαʔόΫϥΠΞϯτؒͷ૯௨৴ྔ ! ͦͷ্ͰదͳॲཧʹϦιʔεΛׂΓͯΔ
ݴޠੑೳ ܾఆతͳࠩʹͳΒͳ͍
Why Go? վળͷޮͷߴ͞ - ߏจ͕SimpleͳͨΊ࣌ؒͷνʔϜ։ൃ͖ - ฒྻɾฒߦॲཧͰͷϝϞϦपΓͷѻָ͍͕ - σϓϩΠָ͕ -
ඪ४ύοέʔδ͕ඇৗʹ࣮༻త
औΓΜͩ͜ͱ 1. ϓϩηεΩϟογϡ 2. λεΫࢄॲཧ
ϓϩηεΩϟογϡ σʔλΛϓϩηε্ʹશͯอ͓࣋ͯ͘͠ ! ӬଓԽదͳλΠϛϯάͰRedisʹอଘͳ ΓϑΝΠϧʹdumpͳΓ͢Δ
߹ੑ વɺෳͷGoroutine͔ΒಡΈॻ͖͞ΕΔ ͨΊͷ߹ੑΛอূ͢Δඞཁ͕͋Δ
Race Condition ڝ߹͢Δมૢ࡞Λߦ͏ͱෆ҆ఆͳڍಈ Goroutine·͍ͨͰڞ༗ͷΛಡΈॻ͖͢Δ ࡍrace conditionΛආ͚ΔͨΊLock͕ඞཁ
sync ֤छͷϩοΫΛѻ͏ύοέʔδ ! sync.RWMutex - ReadΛWriteͰϩοΫϨϕϧΛͨ͠Lock sync/atomic - ΧϯλͳͲͷॲཧΛ࡞Δͷʹॏๅ
atomic.Value from golang1.4 ! ϓϩηε্ʹatomicʹσʔλߋ৽Ͱ͖Δετ Ξͱͯ͠ઃܭ͞Ε͍ͯ·͢
None
ಡΈࠐΈଆ7BMVF͔Β-PBE
ॻ͖ࠐΈଆ-PDLऔͬͨ͋ͱ 7BMVFʹ4UPSF
λεΫͷࢄॲཧ ཁ݅ - ॲཧʹ͔͔࣌ؒΔͷΛඇಉظɺ͔ͭฒߦ࣮ߦ Λ੍ݶ࣮ͯ͠ߦ͍ͨ͠ ! - ը૾ɾಈըͳͲॏෳͯ͠ॲཧͨ͘͠ͳ͍
Task Queueing capacity͖ͷchannelΛ͏ goroutine͕ͦͷ··workerతʹ͑Δ
None
ॏෳॲཧΛආ͚Δ ྫ͑ը૾ॲཧதʹɺͦͷը૾Λऔಘ͠ʹདྷ ΔϦΫΤετΛfailͤͯ͞ͳΒͳ͍ ! ͔͠͠ɺऔಘ࣌ʹॏෳॲཧ͕࣌ؒମແ͍
αʔό͕1ͷ߹
sync.Cond ॲཧதͷͷΛબతʹͭ
None
αʔό͕ෳͷ࣌
y-matsuwitter/mcond ෳͷαʔόؒͰsync.CondΛѻ͑ΔΑ͏ ʹͨ͠ͷ ! Redis + net/httpΛར༻
ೋͷαʔόͰͷmcond
ॲཧଆ ಡΈࠐΈଆ
ॲཧઌΛৼΓ͚Δ
stathat/consistent ίϯγεςϯτϋογϡϥΠϒϥϦ ! Ұఆͷ໊લʹରͯ͠ඞͣಉ͡ॲཧઌΛܾఆ ࠓճଳҬΛ͍௵ͨ͢Ίෳͷwebdav αʔόʹৼΓ͚Δ༻్Ͱར༻
None
ͪͳΈʹ ഊҼCache-Control HeaderͰͨ͠ IUUQTTV[VSJKQZ@NBUTVXJUUFSUTIJSUNCMBDL
࠷ޙʹ
ProductionͰ͓͏
None
ࢀߟ ඪ४ύοέʔδ http://golang.org/pkg/ go1.4 http://tip.golang.org/doc/go1.4 mcond https://github.com/y-matsuwitter/mcond consistent https://github.com/stathat/consistent