Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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.3k
多様性のあるプロダクトチームを目指した共創の3年間の変化 / Three Years of Co-Creation for Diverse Product Teams Change
oomatomo
1
94
事業貢献を見据えた モダナイゼーションへの挑戦
oomatomo
1
53
UXへの投資と組織変革 ─ ビジネスに貢献するUXチームの飛躍 ─
oomatomo
1
43
2016/05/16 adtech x scala meetup のLT
oomatomo
1
77
Finagleを使った Perl -> Scalaへの移行
oomatomo
0
1.9k
Other Decks in Programming
See All in Programming
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
160
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
5
3.9k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
1
120
React CompilerとFine Grained Reactivityと宣言的UIのこれから / The next chapter of declarative UI
ssssota
7
3.4k
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
130
42 best practices for Symfony, a decade later
tucksaun
1
140
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
670
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
1
170
As an Engineers, let's build the CRM system via LINE Official Account 2.0
clonn
1
640
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
130
Arm移行タイムアタック
qnighy
0
410
Discord Bot with AI -for English learners-
xin9le
1
110
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Producing Creativity
orderedlist
PRO
341
39k
Code Reviewing Like a Champion
maltzj
520
39k
Building an army of robots
kneath
302
44k
How STYLIGHT went responsive
nonsquared
95
5.2k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.2k
Adopting Sorbet at Scale
ufuk
73
9.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
790
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Git: the NoSQL Database
bkeepers
PRO
427
64k
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 ͍͍ͬ͢Ͷ
ऴΘΓ