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
事業貢献を考えるための技術改善の目標設計と改善実績 / Targeted design of technical improvements to consider business contribution and improvement performance
oomatomo
0
96
プロダクト開発の貢献をアピールするための目標設計や認知活動 / 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
98
事業貢献を見据えた モダナイゼーションへの挑戦
oomatomo
1
58
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
ソフトウェアの振る舞いに着目し 複雑な要件の開発に立ち向かう
rickyban
0
890
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
770
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
たのしいparse.y
ydah
3
120
Haze - Real time background blurring
chrisbanes
1
510
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
720
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
170
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
720
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
200
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
97
Facilitating Awesome Meetings
lara
50
6.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Code Reviewing Like a Champion
maltzj
520
39k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
RailsConf 2023
tenderlove
29
940
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Statistics for Hackers
jakevdp
796
220k
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 ͍͍ͬ͢Ͷ
ऴΘΓ