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
480
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
1k
プロダクト開発の貢献をアピールするための目標設計や認知活動 / Goal design and recognition activities to promote product development contributions.
oomatomo
5
1.4k
多様性のあるプロダクトチームを目指した共創の3年間の変化 / Three Years of Co-Creation for Diverse Product Teams Change
oomatomo
1
100
事業貢献を見据えた モダナイゼーションへの挑戦
oomatomo
1
70
UXへの投資と組織変革 ─ ビジネスに貢献するUXチームの飛躍 ─
oomatomo
1
44
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
Alba: Why, How and What's So Interesting
okuramasafumi
0
230
Flatt Security XSS Challenge 解答・解説
flatt_security
0
790
AWS Lambda functions with C# 用の Dev Container Template を作ってみた件
mappie_kochi
0
200
ペアーズでの、Langfuseを中心とした評価ドリブンなリリースサイクルのご紹介
fukubaka0825
1
160
Оптимизируем производительность блока Казначейство
lamodatech
0
980
ErdMap: Thinking about a map for Rails applications
makicamel
1
860
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
0
140
ASP. NET CoreにおけるWebAPIの最新情報
tomokusaba
0
170
ISUCON14公式反省会LT: 社内ISUCONの話
astj
PRO
0
130
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
410
HTML/CSS超絶浅い説明
yuki0329
0
200
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
160
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Power of CSS Pseudo Elements
geoffreycrofte
74
5.4k
What's in a price? How to price your products and services
michaelherold
244
12k
Visualization
eitanlees
146
15k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
20
2.4k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
GitHub's CSS Performance
jonrohan
1030
460k
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 ͍͍ͬ͢Ͷ
ऴΘΓ