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
Gaurun / A general push notification server in Go
Search
Tatsuhiko Kubo
June 21, 2015
Technology
11
45k
Gaurun / A general push notification server in Go
Gaurun 〜A general push notification server in Go〜
Tatsuhiko Kubo
June 21, 2015
Tweet
Share
More Decks by Tatsuhiko Kubo
See All by Tatsuhiko Kubo
Handling a tremendous amount of images with Fastly / Yamagoya Traverse 2020
cubicdaiya
2
1.4k
System Integration with Fastly
cubicdaiya
0
570
実例で学ぶ画像最適化集 with ImageFlux / ImageFlux meetup#2
cubicdaiya
4
19k
Software Engineer, Infrastructure
cubicdaiya
4
3.1k
High Performance Count Up!
cubicdaiya
0
320
ImageFluxを利用した画像配信の最適化 / ImageFlux meetup 201801
cubicdaiya
0
2.8k
Building high performance push notification server in Go
cubicdaiya
5
3.2k
メルカリのデータ分析基盤 / mercari data analysis infrastructure
cubicdaiya
11
11k
On-call Engineering
cubicdaiya
8
6.5k
Other Decks in Technology
See All in Technology
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
TypeScript、上達の瞬間
sadnessojisan
46
13k
Terraform Stacks入門 #HashiTalks
msato
0
360
AI前提のサービス運用ってなんだろう?
ryuichi1208
8
1.4k
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
13k
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
130
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
150
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
490
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
140
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Faster Mobile Websites
deanohume
305
30k
YesSQL, Process and Tooling at Scale
rocio
169
14k
A better future with KSS
kneath
238
17k
Producing Creativity
orderedlist
PRO
341
39k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
KATA
mclloyd
29
14k
Transcript
A general push notification server in Go Tatsuhiko Kubo@cubicdaiya Go
Conference summer@2015/06/21 Gaurun
@cubicdaiya / Tatsuhiko Kubo w 4PGUXBSF&OHJOFFS!.FSDBSJ *OD w *OGSBTUSVDUVSF&OHJOFFSJOH w
(P w OHJOYCVJME TMBDLCPBSE (BVSVO w OHJOY w OHY@TNBMM@MJHIU OHY@EZOBNJD@VQTUSFBN
Other Activities IUUQNP[BJDGNQPTUOHJOY
None
None
mercari.go w DVCJDEBJZBOHJOYCVJME w DVCJDEBJZBDBDIFDUM w DVCJDEBJZBTMBDLCPBSE w NFSDBSJ(BVSVO (PJOQSPEVDUJPO!.FSDBSJ
mercari.go w DVCJDEBJZBOHJOYCVJME w DVCJDEBJZBDBDIFDUM w DVCJDEBJZBTMBDLCPBSE w NFSDBSJ(BVSVO (PJOQSPEVDUJPO!.FSDBSJ
Gaurun https://github.com/mercari/gaurun
Gaurun w "HFOFSBMQVTIOPUJpDBUJPOTFSWFS GPSTNBSUQIPOFBQQMJDBUJPOT w 8SJUUFOJO(P w QSPYJOHQVTISFRVFTUTUP"1/TBOE($. w 4JNQMF)551"1*T
Overview ($. "1/T (BVSVO )5514 "1/T QSPUPDPM )551 1045QVTI #PEZJT+40/
$MJFOU
Why Go? w 3FRVJSFNFOUT w (PPEQFSGPSNBODF w )JHIDPODVSSFODZ w OFUIUUQJTHPPEDIPJDF
Why Go? w 1VTIJTTMPX w %VFUPOFUXPSLMBUFODZ w 4PNFPQFSBUJPO!.FSDBSJ w 4FOENJMMJPOQVTIBUPODFʂ
w )JHIDPODVSSFODZJTSFRVJSFEʂ
Why Go? w "TZODSPOPVTQVTIJTSFRVJSFE w QVTIJTUSJHHFSFEJO"1*TFSWFS w DPNNFOU MJLF CVZ
TFMM w "1*TFSWFSNVTUSFTQPOTFRVJDLMZ w "TZODISPOJ[BUJPOJTDPNQMJDBUFE w "1*TFSWFS!.FSDBSJJT"QBDIF 1)1
Push System @ Mercari
a year ago… ($. "1/T "1*4FSWFS "1*4FSWFS "1*4FSWFS "MMQVTIOPUJpDBUJPOTBSFTZODISPOPVT QVTI
half a year ago… ($. "1/T 8PSLFS "MMQVTIOPUJpDBUJPOTBSFBTZODISPOPVT 2VFVF 8PSLFS
8PSLFS QVTI EFRVFVF "1*4FSWFS "1*4FSWFS #BUDI4FSWFS FORVFVF "1*4FSWFS
But very complicated… w +PC2VFVF w 2. w .VMUJ1SPDFTT8PSLFSXJUI1)1 w
1)11BSBMMFMT1SFGPSL w 5IFBSDIJUFDUVSFJTOPUTDBMBCMF
Now… ($. "1/T (BVSVO (BVSVO (BVSVO /(*/9 "1*4FSWFS "1*4FSWFS "1*4FSWFS
#BUDI4FSWFS QVTI XJUI LFFQBMJWF )551 1045QVTI
Gaurun Internals
How Gaurun pushesʁ ($. "1/T (BVSVO )5514 "1/T QSPUPDPM )551
1045QVTI #PEZJT+40/ $MJFOU
Bootstrap Gaurun UIFDPEFCFMPXJTTJNQMJpFEGPSFYQMBOBUJPO TUBSUXPSLFSTGPSQVTI HBVSVO4UBSU1VTI8PSLFST XPSLFS/VN RVFVF/VN )551"1*T IUUQ)BOEMF'VOD
lQVTIz HBVSVO1VTI/PUJpDBUJPO)BOEMFS IUUQ)BOEMF'VOD lTUBUHPz TUBUT(P)BOEMFS IUUQ)BOEMF'VOD lTUBUBQQz HBVSVO4UBUT(BVSVO)BOEMFS ʜ TUBSU)551TFSWFS IUUQ-JTUFO"OE4FSWF lz OJM
start workers for push UIFDPEFCFMPXJTTJNQMJpFEGPSFYQMBOBUJPO GVOD4UBSU1VTI8PSLFST XPSLFS/VN RVFVF/VNJOU \ 2VFVFNBLF
DIBO/PUJpDBUJPO RVFVF/VN GPSJJXPSLFS/VNJ \ HPQVTI/PUJpDBUJPO8PSLFS ^ ^
POST /push UIFDPEFCFMPXJTTJNQMJpFEGPSFYQMBOBUJPO GVOD1VTI/PUJpDBUJPO)BOEMFS XIUUQ3FTQPOTF8SJUFS S IUUQ3FRVFTU \ BDDFQUTPOMZ1045NFUIPE NFUIPE$IFDL
SFBESFRVFTUCPEZ SCPEZ @JPVUJM3FBE"MM S#PEZ QBSTFSFRVFTUCPEZ WBSSFR(BVSVO3FRVFTU(BVSVO @KTPO6ONBSTIBM SCPEZ SFR(BVSVO FORVFVFOPUJpDBUJPOBTZODISPOPVTMZ HPFORVFVF/PUJpDBUJPOT SFR(BVSVO/PUJpDBUJPOT SFUVSOUIFSFTQPOTF TFOE3FQPOTF X lPLz IUUQ4UBUVT0, ^
enqueue Notifications UIFDPEFCFMPXJTTJNQMJpFEGPSFYQMBOBUJPO GVODFORVFVF/PUJpDBUJPOT OT<>3FRVFTU/PUJpDBUJPO \ GPS@ OPUJpDBUJPOSBOHFOT\ 2VFVFOPUJpDBUJPO ^
^
pushNotificationWorker UIFDPEFCFMPXJTTJNQMJpFEGPSFYQMBOBUJPO GVODQVTI/PUJpDBUJPO8PSLFS \ GPS\ OPUJpDBUJPO2VFVF TXJUDIOPUJpDBUJPO1MBUGPSN\ DBTF1MBUGPSN*PT QVTI/PUJpDBUJPO*PT
DBTF1MBUGPSN"OESPJE QVTI/PUJpDBUJPO*"OESPJE ^ ^ ^
Why workers with goroutine and queue with channel are static?
w 6OMJNJUFEHPSPVUJOFT w 1FSGPSNBODFTMPXTEPXO w #FDBVTFQVTIJTTMPX w DIBOOFMJTSFRVJSFEGPSLFFQJOHXPSLFSTXBJUJOH w (P`TDIBOOFMTJ[FJTOPUVOMJNJUFE
Gaurun Features
HTTP APIs w 1045QVTI w (&5TUBUHP w (&5TUBUBQQ
POST /push "DDFQUTCVMLFEQVTISFRVFTUXJUI+40/ \ lOPUJpDBUJPOz< \ lUPLFOTz<lYYYz> lQMBUGPSNz
lNFTTBHFzl)FMMP J04z lCBEHFz lTPVOEzlEFGBVMUz lFYQJSZz ^ \ lUPLFOTz<lZZZz> lQMBUGPSNz lNFTTBHFzl)FMMP "OESPJEz lDPMMBQTF@LFZzlVQEBUFz lEFMBZ@XIJMF@JEMFzUSVF lUJNF@UP@MJWFz ^ > ^
GET /stat/go DVSMTIUUQTUBUHP \ lUJNFz lHP@WFSTJPOzlHPz lHP@PTzlMJOVYz
lHP@BSDIzlBNEz lDQV@OVNz lHPSPVUJOF@OVNz lHPNBYQSPDTz lDHP@DBMM@OVNz lNFNPSZ@BMMPDz lNFNPSZ@UPUBM@BMMPDz lNFNPSZ@TZTz lNFNPSZ@MPPLVQTz lNFNPSZ@NBMMPDTz lNFNPSZ@GSFFTz ɾ ɾ ɾ 3FUVSOTBTUBUJDUJDTGPS(PSVOUJNF
GET /stat/app DVSMTIUUQTUBUBQQ \ lRVFVF@NBYz lRVFVF@VTBHFz lJPTz\ lQVTI@TVDDFTTz
lQVTI@FSSPSz ^ lBOESPJEz\ lQVTI@TVDDFTTz lQVTI@FSSPSz ^ ^ 3FUVSOTBTUBUJDUJDTGPS(BVSVO
More details… IUUQTHJUIVCDPNNFSDBSJHBVSVOCMPCNBTUFS41&$NE
Gaurun Configuration HBVSVODHBVSVOUPNM
Gaurun Configuration (TOML) <DPSF> QPSUlz XPSLFST RVFVFT <BOESPJE> BQJLFZlʜz <JPT>
QFN@DFSU@QBUIlQBUIDFSUQFNz FN@LFZ@QBUIlQFNLFZQFNz TBOECPYGBMTF UJNFPVU@FSSPS
Optimization w DPSFXPSLFST w OVNCFSPGXPSLFSTGPSQVTI w DPSFRVFVFT w TJ[FPGDIBOOFMGPSQVTIXPSLFST w
JPTUJNFPVU@FSSPS w UJNFPVUGPSXBJUJOHFSSPSGSPN"1/T w EFGBVMUDPOpHVSBUJPOJTDPTFSWBUJWF
More details… IUUQTHJUIVCDPNNFSDBSJHBVSVOCMPCNBTUFS$0/'*(63"5*0/NE
Monitoring Gaurun
Monitoring Gaurun w (&5TUBUHP w 3FUVSOTBTUBUJDUJDTGPS(PSVOUJNF w (&5TUBUBQQ w 3FUVSOTBTUBUJDUJDTGPS(BVSVO
Monitoring Gaurun with Zabbix VTFSQBSBNFUFS@HPMBOH@TUBUTDPOG 6TFS1BSBNFUFSHPMBOHTUBUT< > DVSMTIUUQTUBUHPcKR
Monitoring server written in Go w .FNPSZVTBHFBOEBMMPDBUJPOT w ($DPOEJUJPO w
OVNCFSPGHPSPVUJOFT w DIBOOFMVTBHF w OVNCFSPGDPOOFDUJPOT SFRVFTUTTFD FUDʜ
The case of Gaurun w (&5TUBUHP w .FNPSZVTBHFBOEBMMPDBUJPOT w ($DPOEJUJPO
w OVNCFSPGHPSPVUJOFT w (&5TUBUBQQ w DIBOOFMVTBHF w OHY@IUUQ@TUVC@TUBUVT@NPEVMF w OVNCFSPGDPOOFDUJPOT SFRVFTUTTFD FUDʜ
Potential problems w HPSPVUJOFMFBL w -JOFBSJODSFBTFPGOVNCFSPGHPSPVUJOFT w *U`TBNPSFTFSJPVTCVHUIBONFNPSZMFBL w DIBOOFMCMPDLJOH
w DIBOOFMTJ[FJTMJNJUFE
Library For Monitoring Go-runtime w GVLBUBHPMBOHTUBUTBQJIBOEMFS w 7FSZVTFGVM w (&5TUBUHPJTQPXFSFECZUIJT
Summary w (PJTTVJUBCMFGPSTJNQMF)551"1*TFSWFS w (BVSVOXPSLTpOF w .POJUPSJOHTFSWFSXSJUUFOJO(P w $BSFQPUFOUJBMQSPCMFNTCMPX w
HPSPVUJOFMFBL w DIBOOFMCMPDLJOH
ਓࡐืूதʂ