Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
5k
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
480
非同期開発体制を支えるドキュメント文化 / YAPC::Hiroshima 2024
konboi
28
13k
様々な環境へコマンドラインツールを提供する上での苦労とその対策 / YAPC::Kyoto 2023
konboi
0
3.1k
煩雑な運用を Goを使って楽にする / Go Conference 2019 Spring
konboi
4
4.8k
あなたってどんな方(型)?/ kamakura.go#4
konboi
1
710
中規模チームを支える自動化とノウハウ共有の仕組み/CEDEC2017
konboi
8
9.9k
golang tokyo #6 / ゲーム開発には欠かせない?! あれをシュッと見る
konboi
1
7.9k
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
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
650
Deep Data Security 機能解説
oracle4engineer
PRO
2
800
LocalStack を使ったサーバーレスアプリケーション開発 / Serverless Development with LocalStack
kakakakakku
1
420
しろおびから始める!ログ活用の第一歩
shumei_ito
0
920
使いこなすために知っておきたい Azure SRE Agent アンチパターン
torumakabe
2
480
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
0
120
How to Design Configuration for Rails Applications
willnet
0
210
不可逆な意思決定を避けながら10億超の顧客データを AI Ready にするデータ基盤設計
baseballyama
1
310
組み立てて楽しむ AWS Blocks 入門
kmiya84377
0
230
転んだ話が背中を預ける理由になる / A_story_about_falling_down_gives_you_a_reason_to_watch_each_other_s_backs.pdf
pauli
3
360
遠藤な_めぐろLT #38 「社内のAI活用推進」@麻布台_20261009
endonanana
0
120
パッチ更新でterraform initが落ちた日
grimoh
1
120
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
370
エンジニアに許された特別な時間の終わり
watany
109
250k
Are puppies a ranking factor?
jonoalderson
2
4k
Optimizing for Happiness
mojombo
378
71k
Designing for Timeless Needs
cassininazir
1
520
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
450
The Limits of Empathy - UXLibs8
cassininazir
2
720
Producing Creativity
orderedlist
PRO
348
41k
Utilizing Notion as your number one productivity tool
mfonobong
4
620
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
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ੜ׆Λʂ
! ͝੩ௌ ! ͋Γ͕ͱ͏͍͟͝·ͨ͠