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
Finagleを使った広告配信基盤
Search
Tomohisa Omagari
March 10, 2017
Programming
0
470
Finagleを使った広告配信基盤
Tomohisa Omagari
March 10, 2017
Tweet
Share
More Decks by Tomohisa Omagari
See All by Tomohisa Omagari
プロダクト開発の貢献をアピールするための目標設計や認知活動 / Goal design and recognition activities to promote product development contributions.
oomatomo
5
1.2k
多様性のあるプロダクトチームを目指した共創の3年間の変化 / Three Years of Co-Creation for Diverse Product Teams Change
oomatomo
1
72
事業貢献を見据えた モダナイゼーションへの挑戦
oomatomo
1
46
UXへの投資と組織変革 ─ ビジネスに貢献するUXチームの飛躍 ─
oomatomo
1
43
2016/05/16 adtech x scala meetup のLT
oomatomo
1
76
Finagleを使った Perl -> Scalaへの移行
oomatomo
0
1.9k
Other Decks in Programming
See All in Programming
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
Jakarta EE meets AI
ivargrimstad
0
560
CSC509 Lecture 09
javiergs
PRO
0
140
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
1.9k
Contemporary Test Cases
maaretp
0
140
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
920
Outline View in SwiftUI
1024jp
1
330
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
610
Featured
See All Featured
Building an army of robots
kneath
302
43k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Fireside Chat
paigeccino
34
3k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
The Language of Interfaces
destraynor
154
24k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
How STYLIGHT went responsive
nonsquared
95
5.2k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Practical Orchestrator
shlominoach
186
10k
Transcript
FinagleΛͬͨ ࠂ৴ج൫
ࣗݾհ େۂஐٱ COMPANY SERVICE GitHub oomatomo
͢༰ ▸ ࣮ࡍʹFinagleΛͬͯΈͯɺؾ͍ͮͨTipsతͳ༰ ▸ Finagleͷઆ໌ɺ͋·Γ͠ͳ͍ɻ
ΞδΣϯμ ▸ Finagleͱʁ ▸ ࠂ৴ͷྲྀΕ ▸ ৴ج൫ʹؔͯ͠ ▸ Finagleͷίʔυͷߏ ▸
FinagleͷνϡʔχϯάͰͷؾ͖ͮ
ΞδΣϯμ ▸ Finagleͱʁ ▸ ࠂ৴ͷྲྀΕ ▸ ৴ج൫ʹؔͯ͠ ▸ Finagleͷίʔυͷߏ ▸
FinagleͷνϡʔχϯάͰͷؾ͖ͮ
Finagle ▸ ϑΟωʔάϧ ▸ Twitter ͕։ൃͨ͠OSS ▸ RPCγεςϜ RPCͷ࣮Ͱͳ͍ ▸
https://twitter.github.io/finagle/ ▸ https://monkey.org/~marius/talks/twittersystems/#1
ΞδΣϯμ ▸ Finagleͱʁ ▸ ࠂ৴ͷྲྀΕ ▸ ৴ج൫ʹؔͯ͠ ▸ Finagleͷίʔυͷߏ ▸
FinagleͷνϡʔχϯάͰͷؾ͖ͮ
ࠂ৴ͷྲྀΕ
ࠂ৴ͷྲྀΕ ৴෦
ࠂ৴ͷྲྀΕ ूܭ෦
ࠓճ ৴෦ʹ͍ͭͯ ͠·͢
ΞδΣϯμ ▸ Finagleͱʁ ▸ ࠂ৴ͷྲྀΕ ▸ ৴ج൫ʹؔͯ͠ ▸ Finagleͷίʔυͷߏ ▸
FinagleͷνϡʔχϯάͰͷؾ͖ͮ
৴ج൫ʹؔͯ͠
৴ج൫ʹؔͯ͠
σʔϞϯ༻αʔό ৴ج൫ʹؔͯ͠
σʔλΛγϦΞϥΠζͯ͠ Redisʹอଘ͢Δ ৴ج൫ʹؔͯ͠
ActorΛεέδϡʔϦϯάͰ ಈ͔ͯ͠σʔϞϯͱͯ͠ར༻ ͜͜ͷσʔϞϯͷ࣮ͷํɺผͷൃදࢿྉʹ͋Γ·͢ɻ https://speakerdeck.com/oomatomo/16-adtech-x-scala-meetup-falselt ৴ج൫ʹؔͯ͠
ࠂ৴༻αʔό ৴ج൫ʹؔͯ͠
ࠂͷϦΫΤετ ͯ͢ࠂ৴༻αʔόͷ1Ͱ ݁͢Δ ৴ج൫ʹؔͯ͠
ΞδΣϯμ ▸ Finagleͱʁ ▸ ࠂ৴ͷྲྀΕ ▸ ৴ج൫ʹؔͯ͠ ▸ Finagleͷίʔυͷߏ ▸
FinagleͷνϡʔχϯάͰͷؾ͖ͮ
Finagleͷίʔυͷߏʹؔͯ͠
Finagleͷίʔυͷߏʹؔͯ͠ ϏδωεϩδοΫͷஔ͖ Service͔ΒݺΕΔ ݱঢ়ίʔυྔଟ͘ͳ͍ͷͰ Redis͔Βͷσʔλͷऔಘͷॲཧͱ͔ ॻ͍͍ͯΔ
Finagleͷίʔυͷߏʹؔͯ͠ Ϟσϧͷஔ͖ LogicServiceͰར༻͢ΔΫϥε͕ ॻ͍ͯ͋Δ
Finagleͷίʔυͷߏʹؔͯ͠ FinagleͷServiceͷஔ͖ Play FrameworkͰݴ͏ ControllerΈ͍ͨͳͷ
Finagleͷίʔυͷߏʹؔͯ͠
Finagleͷίʔυͷߏʹؔͯ͠
Finagleͷίʔυͷߏʹؔͯ͠ ڞ௨ॲཧͷஔ͖ ServiceLogicͰར༻͢Δ ศརܥͷॲཧ͕͜͜ʹ͋Δ
Finagleͷίʔυͷߏʹؔͯ͠ ϝΠϯΫϥε RouterHttpαʔόͷىಈͳͲΛ ߦ͍ͬͯΔ
Finagleͷίʔυͷߏʹؔͯ͠
Finagleͷίʔυͷߏʹؔͯ͠ graceful stop ࣮͍ͯ͠ͳ͍ͷͰ ࠶ىಈ࣌ϩʔυόϥϯαʔ͔Β ֎ͯ͠࠶ىಈ͍ͯ͠Δ
Finagleͷίʔυͷߏʹؔͯ͠ ▸ Unitςετ
Finagleͷίʔυͷߏʹؔͯ͠ ▸ Unitςετ https://github.com/twitter/finagle/blob/finagle-6.35.0/finagle-redis/src/test/scala/com/twitter/finagle/redis/RedisTest.scala finagle-redisͷςετίʔυΛࢀߟʹ࡞ͨ͠
Finagleͷίʔυͷߏʹؔͯ͠ ▸ Unitςετ
Finagleͷίʔυͷߏʹؔͯ͠ ▸ E2Eςετ
Finagleͷίʔυͷߏʹؔͯ͠ ▸ E2Eςετ
Finagleͷίʔυͷߏʹؔͯ͠ ▸ E2Eςετ ςετ༻ʹαʔόͱΫϥΠΞϯτΛੜ͢Δ
Finagleͷίʔυͷߏʹؔͯ͠ ▸ E2Eςετ ϦΫΤετΛੜ࣮͠ߦ͢Δ
Finagleͷίʔυͷߏʹؔͯ͠ ▸ E2Eςετ ϨεϙϯεΛνΣοΫ͢Δ
ΞδΣϯμ ▸ Finagleͱʁ ▸ ࠂ৴ͷྲྀΕ ▸ ৴ج൫ʹؔͯ͠ ▸ Finagleͷίʔυͷߏ ▸
FinagleͷνϡʔχϯάͰͷؾ͖ͮ
ͱΓ͋͑ͣɺಈ͘ͷ࡞ͬͯ ෛՙςετΛ࣮ࢪͨ͠ɻ
500 QPS ΠϯελϯελΠϓ: c4large
▸ RedisͰ͋ΔҰఆҎ্ίωΫγϣϯ͕૿͑ͳ͍ ▸ Future(ඇಉظ)Λ׆͔ͨ͠ઃܭ ▸ Routerͷॻ͖ํ࣍ୈͰ ϦΫΤετͷͨͼʹΠϯελϯε͕ੜ͞ΕΔ
RedisͰ͋ΔҰఆҎ্ ίωΫγϣϯ͕ ૿͑ͳ͍
RedisͰ͋ΔҰఆҎ্ίωΫγϣϯ͕૿͑ͳ͍ ▸ ௨ৗͷredisͷClientͷ࡞Γํ
RedisͰ͋ΔҰఆҎ্ίωΫγϣϯ͕૿͑ͳ͍ ▸ ௨ৗͷredisͷClientͷ࡞Γํ
RedisͰ͋ΔҰఆҎ্ίωΫγϣϯ͕૿͑ͳ͍ ▸ ௨ৗͷredisͷClientͷ࡞Γํ https://github.com/twitter/finagle/blob/finagle-6.35.0/finagle-redis/src/main/scala/com/twitter/finagle/redis/Client.scala ▸ ࣮ࡍʹClientΛੜ͍ͯ͠Δίʔυ(Finagleͷόʔδϣϯɺ6.35.0)
RedisͰ͋ΔҰఆҎ্ίωΫγϣϯ͕૿͑ͳ͍ ▸ ௨ৗͷredisͷClientͷ࡞Γํ https://github.com/twitter/finagle/blob/finagle-6.35.0/finagle-redis/src/main/scala/com/twitter/finagle/redis/Client.scala ▸ ࣮ࡍʹClientΛੜ͍ͯ͠Δίʔυ(Finagleͷόʔδϣϯɺ6.35.0)
RedisͰ͋ΔҰఆҎ্ίωΫγϣϯ͕૿͑ͳ͍ ▸ ΧελϚΠζͨ͠Clientͷ࡞Γํ ( 1 -> 10000 )
500 QPS → 1350 QPS ΠϯελϯελΠϓ: c4large
RedisͰ͋ΔҰఆҎ্ίωΫγϣϯ͕૿͑ͳ͍ ▸ ΧελϚΠζͨ͠Clientͷ࡞Γํ ( 1 -> 10000 ) ࠷৽൛(6.42.0)Ͱ Clientͷੜͷํ๏͕มߋ͞Ε͍ͯΔͨΊ
͜ͷॻ͖ํग़དྷͳ͍ʂʂʂ
Future(ඇಉظ)Λ ׆͔ͨ͠ઃܭ
Future(ඇಉظ)Λ׆͔ͨ͠ઃܭ ▸ ࠷ॳͷઃܭ
Future(ඇಉظ)Λ׆͔ͨ͠ઃܭ ▸ ࠷ॳͷઃܭ
Future(ඇಉظ)Λ׆͔ͨ͠ઃܭ ▸ ฒྻͰ͖ΔΑ͏ʹΩʔΛมߋ
Future(ඇಉظ)Λ׆͔ͨ͠ઃܭ ▸ ฒྻͰ͖ΔΑ͏ʹΩʔΛมߋ
1350 QPS → 1750 QPS ΠϯελϯελΠϓ: c4large
Routerͷॻ͖ํ࣍ୈͰ ϦΫΤετͷͨͼʹ Πϯελϯε͕ ੜ͞ΕΔ
Routerͷॻ͖ํ࣍ୈͰϦΫΤετͷͨͼʹΠϯελϯε͕ੜ͞ΕΔ ▸ /user/1 ͷ࣮(Before)
Routerͷॻ͖ํ࣍ୈͰϦΫΤετͷͨͼʹΠϯελϯε͕ੜ͞ΕΔ ▸ /user/1 ͷ࣮(Before) ͜ͷॻ͖ํΛߦ͏ͱຖճϦΫΤετͷʹ UserService͕ੜ͞Ε͓ͯΓແବʹܨ͕Δ
Routerͷॻ͖ํ࣍ୈͰϦΫΤετͷͨͼʹΠϯελϯε͕ੜ͞ΕΔ ▸ /user/1 ͷ࣮ (After) RouterଆͰidͷऔಘΛఘΊͯ ϦΫΤετͷURL͔Βਖ਼نදݱΛ ͬͯऔಘ͢ΔΑ͏ʹ͢Δ
Routerͷॻ͖ํ࣍ୈͰϦΫΤετͷͨͼʹΠϯελϯε͕ੜ͞ΕΔ ▸ /user/1 ͷ࣮ (After) ࣄલʹServiceΫϥεΛnew͓ͯ͘͠ͱ ϦΫΤετͷʹΠϯελϯε͕ੜ͞Εͳ͍
1750 QPS → 1600 QPS ΠϯελϯελΠϓ: c4large
1750 QPS → 1600 QPS ΠϯελϯελΠϓ: c4large Լ͕ͬͨʂʂʂʂʂʂʂʂʂ ਖ਼نදݱͷॲཧͷํ͕ॏ͔ͬͨͷ͔ͳʁʁ ͜ͷमਖ਼ෆ࠾༻ʹ͠·ͨ͠ʂ
·ͱΊ
·ͱΊ ▸ Finagle ͍͍ͬ͢Ͷ
ऴΘΓ