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
RedisのCPU負荷対策パターン
Search
Yuuki Tsubouchi (yuuk1)
August 19, 2017
Programming
2
29k
RedisのCPU負荷対策パターン
by id:y_uuki
Yuuki Tsubouchi (yuuk1)
August 19, 2017
Tweet
Share
More Decks by Yuuki Tsubouchi (yuuk1)
See All by Yuuki Tsubouchi (yuuk1)
MetricSifter:クラウドアプリケーションにおける故障箇所特定の効率化のための多変量時系列データの特徴量削減 / FIT 2024
yuukit
2
120
工学としてのSRE再訪 / Revisiting SRE as Engineering
yuukit
19
11k
Cloudless Computingの論文紹介
yuukit
2
420
#SRE論文紹介 Detection is Better Than Cure: A Cloud Incidents Perspective V. Ganatra et. al., ESEC/FSE’23
yuukit
3
1.5k
エンジニアのためのSRE論文への招待 / Introduction to SRE Papers for Engineers
yuukit
2
11k
博士課程での研究まとめ 2023年1月版 / Summary of my research in the PhD course
yuukit
1
250
AI時代に向けたクラウドにおける信頼性エンジニアリングの未来構想 / DICOMO2022 6A-1
yuukit
7
2.9k
AIOps研究録―SREのための システム障害の自動原因診断 / SRE NEXT 2022
yuukit
10
12k
Interactive AIOps
yuukit
0
2.1k
Other Decks in Programming
See All in Programming
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
110
Better Code Design in PHP
afilina
PRO
0
120
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
310
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
Macとオーディオ再生 2024/11/02
yusukeito
0
370
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1k
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
910
イベント駆動で成長して委員会
happymana
1
320
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
330
Contemporary Test Cases
maaretp
0
130
Featured
See All Featured
Designing Experiences People Love
moore
138
23k
Facilitating Awesome Meetings
lara
50
6.1k
Building an army of robots
kneath
302
43k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
A Modern Web Designer's Workflow
chriscoyier
693
190k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Transcript
ͦͯ͠ޠ Կ͔ͷRedis CPU ෛՙରࡦΛܴ͑Δ
None
RedisͷCPUෛՙରࡦ ύλʔϯ id:y_uuki Kyoto.ͳΜ͔#3
Redis ͔ͭͬͯ·͔͢ʁ
None
RedisͰCPUফඅ͕ϘτϧωοΫʹͳΔέʔε • ܦݧతʹඵؒສίϚϯυ҆ • ΫΤϦͷछྨΞΫηεύλʔϯʹΑͬͯɺ ಉ͡ϋʔυΣΞͰ͋ͬͯCPUར༻ม Խ͢Δ • CPUੑೳʹΑͬͯɺಉ͡ϫʔΫϩʔυͰ͋ͬ ͯCPUར༻มԽ͢Δ
RedisͷCPUϦιʔεফඅߏ • γϯάϧεϨουͰಈ࡞͢ΔͨΊɺϚϧνί ΞڥͰ͋ͬͯɺ1CPUίΞ͔͑͠ͳ͍ • MySQL/PostgreSQLίωΫγϣϯ͝ͱʹ εϨου/ϓϩηεΛىಈ͢ΔϚϧνεϨο υ/ϓϩηεϞσϧ
RedisͷCPUෛՙͱઓ͏ͨΊʹ ͲͷΑ͏ͳ࡞ઓΛͱΓ͏Δ͔
εέʔϧΞοϓ εέʔϧΞτ CPU1ίΞੑೳ͋͛Δ ਨׂ ࢀর༻εϨʔϒ ਫฏׂ - ࣗલ ਫฏׂ -
Redis Cluster CPUෛՙݮ RedisύΠϓϥΠϯ Lua scripting Linux RPS (Redis modules)
εέʔϧΞοϓ • RedisαʔόͷCPUΫϩοΫΛߴ͍ͷʹมߋ • EC2ͳΒc4ܥͷΠϯελϯε • ίΞΛ૿ͯ͋͠·Γҙຯͳ͍ • CPUར༻͕90%͔Β40%ʹͳͬͨ͜ͱ͕͋Δ •
Xeon E5-2650L v2 @1.70GHz (Ivy Bridge) • Xeon E5-2670 v3 @2.30GHz (Haswell) • CPUΫϩοΫʹରͯ͠ઢܗʹมԽ͢ΔΘ͚Ͱ ͳ͍
CPUෛՙݮ
CPUෛՙݮ - Linux RPS • redisεϨουͱΧʔωϧͷωοτϫʔΫI/Oε ϨουΛผʑͷίΞͰॲཧ͢Δ • RPSͰύέοτॲཧΛCPU0Ͱड͚ͯ •
redisεϨουͷCPU AffinityͰύέοτॲཧͱผ # echo ‘3’ > /sys/class/net/eth0/queues/rx-0/rps_cpus # taskset -pc 3-4 $(cat /run/redis/redis-server.pid)
None
https://speakerdeck.com/yuukit/linux-network-performance-improvement-at-hatena
CPUෛՙݮ - RedisύΠϓϥΠϯ • ΫϥΠΞϯτ͕ϨεϙϯεΛ·ͨͣʹޙଓͷϦΫΤετ Λೖ͢Δ͜ͱͰɺύέοτԟ෮ճΛݮΒ͢ • ωοτϫʔΫI/OॲཧΛ·ͱΊ࣮ͯߦͰ͖ΔͷͰɺCPU ॲཧ͕ݮΔ •
1ճͷread(2)ͰෳͷίϚϯυΛಡΈग़ͤΔͷͰɺγ εςϜίʔϧճ͕ݮΓίϯςΩετεΠονݮΔ • ਅͷRedisύΠϓϥΠϯ(by id:ichirin2501) https://redis.io/topics/pipelining
CPUෛՙݮ - Lua scripting • ͋ΔίϚϯυͷ݁ՌΛ࣍ͷίϚϯυ͕ར༻͠ ͍ͯΔҰ࿈ͷίϚϯυྻύΠϓϥΠϯ࣮ߦ ෆՄ • Lua
scriptingͳΒҰ࿈ͷίϚϯυྻΛluaίʔ υͱͯ͠ૹΓࠐΈɺ݁Ռ͚ͩड͚औΕΔ • ύΠϓϥΠϯಉ༷ɺΫϥΠΞϯτͱͷԟ෮ճ ͕ݮΓɺI/OγεςϜίʔϧΛ·ͱΊΒΕΔ https://redis.io/commands/eval
None
εέʔϧΞτ
εέʔϧΞτ-ࢀর༻εϨʔϒ • RedisϚελʔɾεϨʔϒߏ͕ͱΕΔ • ࢀরΫΤϦΛεϨʔϒʹ͚ͯϚελʔͷෛՙΛ ݮ • εϨʔϒͷલஈʹϩʔυόϥϯα͕ඞཁ • MySQLͳͲͷRDBMSͰΑ͘ͱΒΕΔ࡞ઓ
• ϨϓϦέʔγϣϯԆʹҙ • ॻ͖ࠐΜͩͣͷσʔλ͕·ͩεϨʔϒʹൖ ͍ͯ͠ͳ͍Մೳੑ͕͋Δ
εέʔϧΞτ- ਨׂ • RedisͷϚελʔϊʔυΛෳ༻ҙ͢Δ • ػೳAϚελʔ1Λ͏ɺػೳBϚελʔ2Λ ͏ • ػೳͷͿΜ͚ͩɺϚελʔϊʔυΛӡ༻͢Δίε τ͋Δ
• ͋ΔҰͭػೳͷෛՙ͕ࢧతͳ߹ʹ͑ͳ͍ • Ωϟογϡ༻్ͳΒ͚ͦͩ͜memcachedΛར༻
εέʔϧΞτ- ਫฏׂ • γϟʔσΟϯάͱݺͿ • ಉ͡༻్ͷ֤ΩʔΛෳͷϚελʔϊʔυʹࢄ • ΩʔͱϊʔυͷϚοϐϯάΛࣗͰΔ • Ϛοϐϯάํ๏༷ʑ
• ϢʔβID xxx ϊʔυYʹϚοϓ • ϢʔβID yyy ͷ༨͕ z ͳΒϊʔυXʹϚοϓ • γϟʔυΛ૿ݮͨ͠ͱ͖ͷσʔλ࠶ஔ͕͢͠ ͗ΔͷͰͱʹ͔͘Γͨ͘ͳ͍
εέʔϧΞτ- Redis ClusterʹΑΔਫฏׂ • ࠷ऴԞٛ • Ωʔͷࢄஔͱ࠶ஔ/ϑΣΠϧΦʔόʔͳͲα ϙʔτ • redis-tribͱ͍͏ެࣜπʔϧͰࣗಈ࠶ஔͰ͖Δ
• ࠷6ϊʔυඞཁ • database͕1͔͔ͭ͑͠ͳ͍ • ෳΩʔʹର͢ΔίϚϯυ࣮ߦʹҙ • 1000ϊʔυ͙Β͍·Ͱεέʔϧ͢ΔΒ͍͠
ເ
Redis modules • Redus 4.0͔ΒϞδϡʔϧػೳ͕࣮͞Εͨ • Redisͷ෦APIΛͬͯಠࣗͷσʔλߏ ίϚϯυΛ࣮Ͱ͖ΔʢΒ͍͠ʣ • ΞϓϦέʔγϣϯʹ࠷దԽͨ͠σʔλߏΛ
࡞ΕɺΊͪΌͪ͘ΌCPUޮΑ͘ͳΔͷͰ ʁʁʁʁʁ
εέʔϧΞοϓ εέʔϧΞτ CPU1ίΞੑೳ͋͛Δ ਨׂ ࢀর༻εϨʔϒ ਫฏׂ Redis Cluster CPUෛՙݮ RedisύΠϓϥΠϯ
Lua scripting Linux RPS (Redis modules)
ޠ͔Βઓུ
ઓུΛཱͯΔͨΊʹ ͱΓ͏Δઓज़Λ ͓ͬͯ͘