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: based on real story
Search
Poga Po
March 31, 2012
Programming
16
1.3k
Redis: based on real story
Talk @ NoSQL Taiwan
Poga Po
March 31, 2012
Tweet
Share
More Decks by Poga Po
See All by Poga Po
Spacer - iThome Serverless All-Star
poga
2
250
civic-notebook
poga
0
95
Fuzz Testing and go-fuzz
poga
0
310
everything is log
poga
12
1.8k
g0v intro
poga
0
81
新聞產生器
poga
0
590
RESTful API @ Front-End Developers Taiwan 2014-04-23
poga
3
140
Dependency Management in Go
poga
4
600
Other Decks in Programming
See All in Programming
color-scheme: light dark; を完全に理解する
uhyo
3
310
pylint custom ruleで始めるレビュー自動化
shogoujiie
0
120
GAEログのコスト削減
mot_techtalk
0
120
昭和の職場からアジャイルの世界へ
kumagoro95
1
380
データベースのオペレーターであるCloudNativePGがStatefulSetを使わない理由に迫る
nnaka2992
0
150
How mixi2 Uses TiDB for SNS Scalability and Performance
kanmo
37
14k
SwiftUI Viewの責務分離
elmetal
PRO
1
240
技術を根付かせる / How to make technology take root
kubode
1
250
DROBEの生成AI活用事例 with AWS
ippey
0
130
CDK開発におけるコーディング規約の運用
yamanashi_ren01
2
120
社内フレームワークとその依存性解決 / in-house framework and its dependency management
vvakame
1
560
ペアーズでの、Langfuseを中心とした評価ドリブンなリリースサイクルのご紹介
fukubaka0825
2
320
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
100
18k
Speed Design
sergeychernyshev
27
790
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Building an army of robots
kneath
303
45k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
410
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Transcript
Poga 2012.03.31 based on real story
Hi 你好 Hallo 안녕 ciao salut こんにちは
i Poga
i wear many hats
i wear many hats build products
Product released PARTY? Let’s
Database CPU Utilization
Performance Degrading = Unhappy User = Less Profit
Complex Queries Inefficient schema
Limited Time
None
Just ADD it to your stack
Just ADD it to your stack Not Replace
Special Performance Simple In-memory Atomic
Special Performance Simple In-memory Atomic
Management Problem a.k.a. “We don’t have a MIS”
Dependency Feb 25, 2009 First public beta Oct 14, 2011
Redis 2.4 First external dependency jemalloc Mar 31, 2012
Installation Feb 25, 2009 First public beta Oct 14, 2011
Redis 2.4 First external dependency jemalloc Mar 31, 2012 make install make install
Stable
None
Special Performance Simple In-memory Atomic
Special Performance Simple In-memory Atomic
In-Memory Memcached High Performance Simple Key-Value Redis In-Memory High Performance
Data Structures Persistence Replication ...
Data Structures List, Set, Sorted Set, Hash, String http://redis.io/commands
Understand your problem http://nosql.mypopescu.com/post/18977451039/redis-guide-what-each-redis-data-type-should-be-used Every command in Redis is manipulating
a data structure
Special Performance Simple In-memory Atomic
Special Performance Simple In-memory Atomic
=
http://redis.io/topics/benchmarks FAST for real
Special Performance Simple In-memory Atomic
No Race Condition every command in redis is atomic use
redis as a incremental counter “There are very few systems that support an “increment and return” operation, and Redis is one of them (Oracle sequences are another).” http://nateware.com/2010/02/18/an-atomic-rant/
No Race Condition every command in redis is atomic Combine
multiple command: still atomic! MULTI SET key 123 SET key2 456 EXEC Warning: Don’t confuse with transaction
Special Performance Simple In-memory Atomic
i
Did I make any changes to MySQL? NO It’s still
our main database
Did I solve the problem? YES solve complex queries via
Redis data structure
Happy Database Add Redis to stack
How? Sorted Set: Per user notification String: API request limiter
String, List: Request logging List: Job Queue
Real World = Risk Persistence Replication Sharding
Persistence RDB AOF
RDB • Snapshot • Compact • .rdb file can be
transfered to other backup system • Chances to lose data
AOF • logs of every write operation • durable •
bigger file size
You want a degree of safety comparable to PostgreSQL? Just
use BOTH
Replication Master Slave Slave Slave
Replication • Read-only salves • Save on slaves
Sharding • Memory is limited • Split data into multiple
redis servers
Presharding Single Machine Redis instance Redis instance Redis instance Redis
instance Redis instance Redis instance Redis instance Redis instance Redis instance Redis instance Multiple Machine
Some Case Study • Resque • Rubygems.org • Tumblr •
Instagram
Resque High Performance Job Queue https://github.com/blog/542-introducing-resque
Rubygems.org http://www.scribd.com/doc/34269414/Redis-Persistence-Power feature switch API request limit Logging Job Queue
Tumblr http://engineering.tumblr.com/post/7819252942/staircar-redis-powered-notifications Per-user Notification 30,000 request/s per server
Instagram http://engineering.tumblr.com/post/7819252942/staircar-redis-powered-notifications Simple Key-value mapping 1/3 cost on hardware
Cross server temporary file sharing i Redis string is binary-safe
Future
Future Lua Scripting Watchdog
Lua Scripting Atomic Saving bandwidth between servers
Ruby Redis Sum up 200,000 values ... 200,000 times
Ruby Redis Sum up 200,000 values, with Lua scripting 1
request
Data Model Query Language Scripting MySQL Redis Relational Table SQL
Data Structures Lua Lua
Watchdog Let Redis monitor itself Like slow queries in MySQL
More information to diagnose problem
Bright Future Lua Scripting Watchdog
= Unique
Unique = Not replacing anyone Job security of other database
What will u get
More life less cost Happy User
Thank you question? @devpoga