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の調査についてとrmlp
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Konboi
March 22, 2016
Technology
4.9k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Redisの調査についてとrmlp
shibuya.go#2 での発表資料にします
Konboi
March 22, 2016
More Decks by Konboi
See All by Konboi
Java's OOM and k8s' OOM 遭遇した2つのOOMと対策 ~ Launchableでの事例 ~ / JJUG 2025 Spring
konboi
1
440
非同期開発体制を支えるドキュメント文化 / YAPC::Hiroshima 2024
konboi
28
13k
様々な環境へコマンドラインツールを提供する上での苦労とその対策 / YAPC::Kyoto 2023
konboi
0
3.1k
煩雑な運用を Goを使って楽にする / Go Conference 2019 Spring
konboi
4
4.7k
あなたってどんな方(型)?/ kamakura.go#4
konboi
1
690
中規模チームを支える自動化とノウハウ共有の仕組み/CEDEC2017
konboi
8
9.9k
golang tokyo #6 / ゲーム開発には欠かせない?! あれをシュッと見る
konboi
1
7.8k
git-schemlexとddl-makerを使ったDB migrationの紹介 / git-schemalex and ddl-maker migration #golangtokyo
konboi
1
11k
カヤックの新卒研修 #師弟登壇2015
konboi
0
4k
Other Decks in Technology
See All in Technology
Network Firewallやっていき!
news_it_enj
0
260
10年目を迎えた「ABEMA」がどのように AI 活用を推進して、AI 駆動開発にシフトしているのか / How ABEMA, entering its 10th year, is promoting the use of AI and shifting toward AI-driven development
miyukki
0
370
Alphaモジュール使っていいのかい!?いけないのかい!?どっちなんだいっ!?
watany
1
320
2026年のソフトウェア開発を考える(2026/07版) / Agentic Software Engineering 2026-07 Findy Edition
twada
PRO
25
11k
”AIを使う” から ”AIに任せる” へ ─ 開発プロセスを再設計してAIを組織標準にするまで
cyberagentdevelopers
PRO
1
140
それでも、技術なブログを書く理由 #kichijojipm / Why I Still Write Tech Blogs Even Now
shinkufencer
0
360
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
110k
PHPで作って学ぶリアルタイム音声対話AIとWebSocket入門 by ムナカタ
munakata
0
130
「守りたい体験」を渡すだけで E2E を生成させられるようになった話
hinac0
2
1k
インフラと開発の垣根を超えていき!〜元AWSインフラエンジニアがAWS開発で奮闘している話〜
hatahata021
3
390
インシデント事例と パッケージの全量解析に学ぶ ソフトウェアサプライチェーンの守り方 / supply-chain-attack-defense
flatt_security
0
890
Amazon Quick 入門!
ysuzuki
2
130
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
560
Leo the Paperboy
mayatellez
8
1.9k
Product Roadmaps are Hard
iamctodd
55
12k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
The browser strikes back
jonoalderson
0
1.4k
Navigating Team Friction
lara
192
16k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
270
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
970
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Transcript
Redisͷௐࠪʹ͍ͭͯͱ rmlp shibuya.go#2 3/22
ࣗݾհ • @Konboi • ໘ന๏ਓΧϠοΫ • ϞόΠϧήʔϜͷ։ൃͱӡ༻
ࠓ͢ࣄ • Redisͷௐࠪ • CPU͕ • ϝϞϦ͕ • 1Ͱ •
rmlpʹ͍ͭͯ
ࠓ͞ͳ͍ࣄ • Redisʹ͍ͭͯͷ • Redisͷνϡʔχϯά • GoΛͬͯͷRedisͷૢ࡞
RedisΛۀͰͬͯΔ ͱ͍͏ํ ✋
Redisͷௐࠪʹ͍ͭͯ
ͷલʹ
ӡ༻͍ͯ͠ΔҊ݅Ͱ RedisͷCPU͕͜ͷ༷ʹ ͳͬͨܦݧ͋Γ·͔͢
ಥൃతʹ͕͋ΔCPUෛՙ
None
!
ʹͳΔʹͭΕ͕ͯ͋Δ CPUෛՙ
None
!
ʹʹߴ͘ͳΔCPUෛՙ
None
!!!
ා͍Ͱ͢Ͷ
ͱ͍͏͜ͱͰຊ
CPUͷෛՙ͕ߴ͍࣌
CPUͷෛՙ͕ߴ͍࣌ • ͳʹ͔ॏ͍ॲཧ͕ߦΘΕ͍ͯΔ͕֬ߴ͍Ͱ͢ • RedisγϯάϧεϨουͳͷͰॏ͍ॲཧ͕͋ΔͱͦΕ͕ऴΘ Δ·Ͱଞͷॲཧͨ͞ΕͯͭΒ͍ • ॏ͍ͱ͍ͬͯϛϦඵͰॲཧऴΘΔͷͰؾ͖ͮʹ͍͘ • devͩͱΞΫηε͕গͳ͍ͷͰ࿐ఄ͠ʹ͍͘
Ͳ͏͢Δ...
slow logΛݟ·͠ΐ͏
# ࠓճݕূͷͨΊ slowlogͷ݅Λ10microඵʹ͍ͯ͠·͢ $ redis-cli -h <host> slowlog get <log
num> 1) 1) (integer) 34990 2) (integer) 1457071463 3) (integer) 11 4) 1) "slowlog" 2) "get" 3) "1" ... 3) 1) (integer) 34988 2) (integer) 1457071448 3) (integer) 51 4) 1) "slowlog" 2) "get" 3) "5"
ݟํ 1) 1) (integer) 34990 2) (integer) 1457071463 3) (integer)
11 4) 1) "slowlog" 2) "get" 3) "1" 1) 1) slowlogͷID 2) ࣮ߦऴྃ࣌ͷtimestamp(UNIXඵ) 3) ࣮ߦ࣌ؒ(microඵ) 4) ࣮ߦίϚϯυͱΦϓγϣϯ
CPUͷෛՙ͕ߴ͍࣌ • ͍͍ͩͨ͜ΕͰ͍(ෛՙͷߴ͍)ίϚϯυ͕͔ΔͣͰ͢ • ޙ֘ͷιʔείʔυΛ͠·͠ΐ͏ • ܦݧ্ keys * େྔͷσʔλಉ࢜ͰͷUNION
DIFF Λ͢Δ ͱCPUͷෛՙ͕άϯάϯ্͕Γ·͢
ϝϞϦ
None
ʹʹ૿͑Δσʔλྔ
͜ΕͰ͋ͱXͰ༰ྔ ͷݶքΛܴ͑ͯ͠·͏
!!!
dumpΛऔΓ rdb tool Λͬͯௐࠪ͠·͠ΐ͏
rdb tool ͱ • sripathikrishnan/redis-rdb-tools • Rdbtools is a parser
for Redis' dump.rdb files. • python • rdbϑΝΠϧ͔Βσʔλͷ༷ʑͳใΛग़ྗͰ͖Δπʔϧ
αϯϓϧ dumpslaveͳͲ͔ΒऔΓ·͠ΐ͏ # αʔόʔ͔Βdump $ redis-cli -h <host> --rdb dump.rdb
# memoryͱkeyΛग़ྗ $ rdb -c memory dump.rdb > dump_memory.csv # memoryͷେ͖͞ॱʹsort $ cat dump_memory.csv | awk -F "," '{print $4 "\t" $3'} | sort -n
ϝϞϦ • ༰ྔॱʹstore͞Ε͍ͯΔσʔλ͕Θ͔ΔͷͰ֘ͷσʔλΛ ফ͢ • ඞཁແ͘ͳͬͨσʔλΛআ͢Δ • ܦݧ্ temporary తͳσʔλ͕͍ͬͯΔࣄ͕ଟ͍
• SET <key> <VALUE> "EX" <EXPIRE_TIME> • ͳͲexpire͢Δ࣌ؒΛ͜·Ίʹࢦఆ • ফ͜͠Έॲཧ͕࣮͞Ε͍ͯΔ͔֬ೝ
͖ͪΜͱফ͜͠ΈΛߦ͏ Α͏ʹͨ݁͠Ռ
None
! ! !
ͦΕͰ1Ͱݶք͕...
ׂ͝ͱʹෳʹ͠Α͏ʂ
ׂ͝ͱʹෳʹ͠Α͏ • session༻ • cache༻ • ϥϯΩϯά࡞༻ • ͳͲͳͲ
Ͱͪΐͬͱͬͯ ✋
ͦͷׂຊʹޮ͘...?
ͦͷׂຊʹޮ͘...? • $ redis-cli slowlog get Ͱ͍ίϚϯυ͕Θ͔Δ • rdb tool
Ͱ৭ʑղੳͰ͖Δ • ͜Ε͚ͩͰŊ֤keyͷར༻ස·Ͱ͔Βͳ͍ • ಛఆͷΠϕϯτͷ͚࣌ͩଟ͍͔͠Εͳ͍ • ͋Δkeyͷ࣮ߦ͕΄͔ͷkeyͷ10ഒҎ্͔͠Εͳ͍ • ͳͲ
redis-cli monitor
redis-cli monitor $ redis-cli monitor 1457077479.354522 [0 127.0.0.1:59247] "INCR" "counter:__rand_int__"
1457077479.354621 [0 127.0.0.1:59247] "INCR" 1457077479.352548 [0 127.0.0.1:59245] "SET" "key:__rand_int__" "xxx""counter:__rand_int__" 1457077479.354852 [0 127.0.0.1:59248] "LPUSH" "mylist" "xxx" 1457077479.352812 [0 127.0.0.1:59245] "SET" "key:__rand_int__" "xxx" 1457077479.354522 [0 127.0.0.1:59247] "INCR" "counter:__rand_int__" 1457077479.354621 [0 127.0.0.1:59247] "INCR" "counter:__rand_int__" 1457077479.354852 [0 127.0.0.1:59248] "LPUSH" "mylist" "xxx" 1457077479.353138 [0 127.0.0.1:59245] "SET" "key:__rand_int__" "xxx" ݱࡏ࣮ߦ͞Ε͍ͯΔίϚϯυ͕͔Δ एׯෛՙ͕͕͋ΔͷͰؾΛ͚࣮ͭͯߦ͍ͯͩ͘͠͞
1457077479.354852 [0 127.0.0.1:59248] "LPUSH" "mylist" "xxx" 1457077479.354956 [0 127.0.0.1:59248] "LPUSH"
"mylist" "xxx" <command start timestamp> [<DB> <HOST>] <COMMAND> <KEY> ͳͷͰ2ߦ͔Β1ߦͷtimestampΛҾ͚1ߦͷ࣮ߦ࣌ؒ ͕Θ͔Δ (ݫີͰͳ͍)
ίϚϯυϥΠϯͰΔͱ $ awk 'function fetchcommand() { c =""; for (i
= 4; i < NF; i++) { c = c " " $i }; c = c " " $NF; return c } NR==1 { time=$1; command=fetchcommand() } NR!=1 { print command, $1-time; time=$1; command=fetch_command(); }' /tmp/redis.log surported by @tkuchiki
ίϚϯυʹ͠·ͨ͠
ͬͱGoͷΛ ͪΐΖͬͱ͠·͢
rmlp
rmlp • Konboi/rmlp • Redis Monitor Log Profiler • Go
• ઌ΄ͲͷlogΛݟ͍͢ܗʹܗ • ίϚϯυͷ ฏۉॱ ࣮ߦॱ ࣮ߦճॱ ͰιʔτՄೳ
$ redis-cli monitor > redis-monitor.log $ rmlp -f redis-monitor.log Overall
Stats ================================== LineCount 15000 Commands Rate ================================== LRANGE 4000 PING 2000 ... Heavy Commands ================================== Command Sum(msec) LRANGE 0.803558 PING 0.106445 ... Slowest Calls ================================== KEY Count Max(msec) Avg(msec) PING 2000 0.001511 0.000053 LRANGE mylist 4000 0.001358 0.000201
rmlp • खݩ(Mac)Ͱσόοάͯ͠Ϗϧυ͢Εຊ൪(EC2)Ͱಈ͘࠷ߴ • Ͳͷkey͕ͲͷఔͷසͰൃߦ͞Ε͍ͯΔͷ͔ѲͰ͖Δ • ࿈ଓతʹredis͕ར༻͞Ε͍ͯͳ͍ͱਖ਼֬ͳܭଌ͕Ͱ͖ͳ͍ • ࣍ͷίϚϯυͷ։࢝࣌ؒΛݩʹ࣮ߦ࣌ؒΛग़͍ͯ͠ΔͨΊ •
͚Δඞཁੑ͕͋Δͷ͔ͷஅࡐྉʹͰ͖Δ͔ͳͱ
rmlp • facebookarchive/redis-faina • python • hirose31/redis-traffic-stats • tcpdump࣮ͯ͠ߦ࣌ؒͱසΛܭଌ͢Δπʔϧ͋Δ
ҙࣄ߲ • ࠓճग़ͨ͠ௐࠪͷྫ͋͘·ͰҰྫͰ͢ͷͰଞʹௐࠪํ๏ ͋Δͱࢥ͍·͢ • dumpͱ͔ෛՙͰ࣮αʔϏε͕Өڹͳ͍ঢ়گͰͦ͏ͧ !
շదͳRedisੜ׆Λʂ
! ͝੩ௌ ! ͋Γ͕ͱ͏͍͟͝·ͨ͠