2. About Me
ï Kris jeong(ì êČœì)
ï Author a Book of REDIS
ï âThis is REDISâ in korean
ï Software development
Over 14 years.
ï Web service dev.
ï Messaging server dev.
ï Recommendation dev.
ï Interested about NoSQL
http://www.aladin.co.kr/shop/wproduct.aspx?ISBN=8968480591
3. What is
ï REDIS is In-Memory Database
ï Variety data types
ï Support persistence
ï Key value based NoSQL
4. IMDB(In-Memory DB)
Disk based data store
In-Memory data store
Query Engine
Query Engine
Speed
Storage
Manager
Memory(Cache)
Disk
Memory
Durability
Disk is optional
Disk
5. Redis is cache server?
Not a cache server.
But, It can be.
Turn off Persistence.
7. Install and test
$ wget http://download.redis.io/redis-stable.tar.gz
$ tar xvf redis-stable.tar.gz
$ cd redis-stable
$ make
âŠ
âŠ
done.
$ make test
â» CentOS 6.4 64bit
10. Feature - expire
ï Duration cache
ï expire user:212:cart 259200
seconds
It will be expired 3 days later.
ï Specified time cache
ï expireat user:212:item:sward 1388534400
It will be expired 2014/01/01
Unix timestamp
11. Support data types
ï String
key
value
{
"product": {
"id": "2951",
"name": "testing 01",
"options": {
"color": "red"
},
"quantity": 4
}
user:1:cart_info
}
â» Up to 512MB
12. Support data types (cont.)
ï Hash
Key
field
value
name
min damage
13
max damage
20
durability
32/50
price
item:1:info
bastard sword
3500
add a new value
durability
31/50
13. Support data types (cont.)
ï Hash
Key
field
value
name
min damage
item:1:info
bastard sword
13
max damage
20
durability
31/50
32/50
price
3500
14. Support data types (cont.)
ï List
Key
user:1:messag
e
elements
hi~
how r you.
bye.
add a new value
15. Support data types (cont.)
ï List
Key
user:1:messag
e
elements
hi~
how r you.
bye.
16. Support data types (cont.)
ï Set
kris
mike
frank
user:1:friend
martin
tom
add a new value
chris
17. Support data types (cont.)
ï Set
kris
mike
user:1:friend
frank
martin
tom
chris
18. Support data types (cont.)
ï Sorted Set
score
Key
value
1
91
mike
200
frank
250
martin
251
user:ranking
kris
tom
add a new value
220
chris
19. Support data types (cont.)
ï Sorted Set
Key
score
value
1
91
user:ranking
kris
mike
200
frank
220
250
chris
martin
250
251
martin
tom
251
tom
20. Feature â RDB(Snapshot)
Redis instance
Redis data
Data dump
to disk
Dump file
(Redis.rdb)
When snapshot event raised
Check point of Redis snapshot
ï Redis data size vs Physical memory size ratio
ï vm.overcommit_memory setting
ï Disk I/O rate for swap
21. Feature â AOF(Append Only File)
Redis instance
Command
logging
Redis data
Data change command
Redis client
Check point of Redis aof
ï Disk space
ï Restart time is slower than RDB
appendonly.aof
22. Replication â Single slave
Redis cluster
Master Node
Slave Node
Replication
key1
test value
set key1 âtest valueâ key1
set key1 âtest valueâ
Redis client
test value
25. Sharding â range
â Data range based data split
User Key 1 ~ 100
User Key 1~50
User Key 51~100
Shard 1
Shard 2
Master Node
Master Node
Slave Node
Slave Node
Slave Node
Slave Node
26. Sharding - vertical
â Schema based data split
User info
Content
Shard 1
Shard 2
Master Node
Master Node
Slave Node
Slave Node
Slave Node
Slave Node
27. Sharding - consistent hashing
â Key based data split
User Key 1 ~ 100
Key % Number of Shard(Key % 2)
Shard 1
Shard 2
Master Node
Master Node
Slave Node
Slave Node
Slave Node
Slave Node
28. Sharding â Redis client
Shard 1
Shard N
âŠ
Sharding Calc
Read/Write
Read/Write
Redis client
Check point of Redis Sharding
ï Redis does not support server-side sharding
ï Most Redis client support hash based sharding
ï Re sharding issue
29. Useage
PV/UV Calculation 1Billion user
ï Daily logged in user count
ï Weekly logged in user count
ï List of Logged-in account at least once of week
Most popular News list - Real time
ï Top 10 of news by click count
ï News list by popular by comment count
Real time gamers ranking
ï Score based Top 10 ranker.
ï Recent user list