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
76
事業貢献を見据えた モダナイゼーションへの挑戦
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
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
290
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.4k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
380
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
Macとオーディオ再生 2024/11/02
yusukeito
0
380
Remix on Hono on Cloudflare Workers
yusukebe
1
310
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
180
RubyLSPのマルチバイト文字対応
notfounds
0
120
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.8k
みんなでプロポーザルを書いてみた
yuriko1211
0
280
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Being A Developer After 40
akosma
87
590k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Adopting Sorbet at Scale
ufuk
73
9.1k
GraphQLとの向き合い方2022年版
quramy
43
13k
We Have a Design System, Now What?
morganepeng
50
7.2k
What's new in Ruby 2.0
geeforr
343
31k
Raft: Consensus for Rubyists
vanstee
136
6.6k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
17k
Designing Experiences People Love
moore
138
23k
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 ͍͍ͬ͢Ͷ
ऴΘΓ