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
240
civic-notebook
poga
0
93
Fuzz Testing and go-fuzz
poga
0
290
everything is log
poga
12
1.8k
g0v intro
poga
0
80
新聞產生器
poga
0
560
RESTful API @ Front-End Developers Taiwan 2014-04-23
poga
3
120
Dependency Management in Go
poga
4
580
Other Decks in Programming
See All in Programming
Kotlin 2.0が与えるAndroid開発の進化
masayukisuda
1
420
Method Swizzlingを行うライブラリにおけるマルチモジュール設計
yoshikma
0
120
事業フェーズの変化に対応する 開発生産性向上のゼロイチ
masaygggg
0
210
rails_girls_is_my_gate_to_join_the_ruby_commuinty
maimux2x
0
200
Modern Angular with the NGRX Signal Store New Rules for Your Architecture @BASTA! 2024 in Mainz
manfredsteyer
PRO
0
160
Shinjuku.rb#95:心の技術書紹介
free_world21
1
110
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
2
120
大公開!iOS開発の悩みトップ5 〜iOSDC Japan 2024〜
ryunakayama
0
190
GenU導入でCDKに初挑戦し、悪戦苦闘した話
hideg
0
170
僕が思い描くTypeScriptの未来を勝手に先取りする
yukukotani
9
2.4k
Amazon BedrockでサーバレスなAIお料理ボットを作成する!!
tosuri13
0
230
仮想ファイルシステムを導入して開発環境のストレージ課題を解消する
segadevtech
2
550
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
18
2.9k
The Mythical Team-Month
searls
218
43k
The Cult of Friendly URLs
andyhume
76
6k
How to Ace a Technical Interview
jacobian
274
23k
GraphQLとの向き合い方2022年版
quramy
43
13k
Mobile First: as difficult as doing things right
swwweet
221
8.8k
Docker and Python
trallard
39
3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
23
1.7k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
GitHub's CSS Performance
jonrohan
1030
450k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
123
18k
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