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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
470
非同期開発体制を支えるドキュメント文化 / 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
700
中規模チームを支える自動化とノウハウ共有の仕組み/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
開発投資の期待値を上げるプロダクトロードマップづくり ~プロダクトエンジニアが越境して事業を伸ばす~
kekekenta
1
190
synctest時代のhttptest Go 1.27で変わるHTTPサーバテストの裏側 / go conference2026 synctest and httptest
budougumi0617
1
3k
目の前の楽しいが人生を変える - コミュニティの螺旋の歩き方と楽しむコツ / change your life
soudai
PRO
5
630
俺の仕事は AIに奪われないし、たぶんその BIも要らない
hikaruri
0
500
AI に書かせたその API、 “信頼” できますか?
nagix
0
120
安心して変更できるWebフロントエンドの作り方
pirosikick
5
2.6k
Claude in Chrome 入門 / Introduction to Claude in Chrome
cielo1985
0
840
今話題のAI「Jev」って何? 宇宙最速で学ぶ会
minorun365
PRO
26
15k
品質と信頼性を地続きにする
grimoh
0
520
事業課題から技術的負債に向き合う
sansantech
PRO
2
1.9k
銀行勘定系システムにおける開発プロセス刷新×AIによる環境モダナイゼーション / Development Process Transformation and AI-Driven Environment Modernization
muit
1
2.3k
アプリをもっと"iOSアプリっぽく"する小さな工夫 / Small Touches That Make Your App Feel More Like an iOS App
matsuji
2
930
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
990
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Building the Perfect Custom Keyboard
takai
2
870
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
390
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Exploring anti-patterns in Rails
aemeredith
4
510
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
320
The Curious Case for Waylosing
cassininazir
1
510
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ੜ׆Λʂ
! ͝੩ௌ ! ͋Γ͕ͱ͏͍͟͝·ͨ͠