2. PRESENTED
BY
1 Coupang <3 Redis
Why Coupang loves Redis and how we are using it.
2 RedisJSON
Redis module for JSON.
3 Benchmark Results
Comparing performance between String vs. Hash vs. RedisJSON.
Agenda:
10. PRESENTED
BY
<customer_key> = {
"<ad_id>": {
"weekly": { // frequency type
"epoch": 1565025511888, // timestamp of first ad served
"cap": 7 // count of impressions
},
"daily": {
"epoch": 1565025511888,
"cap": 1
}
},
"<ad_id>": ...
}
<customer_key> = ...
Data Model: JSON
11. PRESENTED
BY
String vs. Hash commands for JSON
Type Commands
String 127.0.0.1:6379> GET customer24
(increment a single field)
127.0.0.1:6379> SET customer24 '{"ad1": {"daily": {"cap": 2020}}}'
Hash 127.0.0.1:6379> HGETALL customer24
(increment a single field)
127.0.0.1:6379> HSET customer24 ad1 '{"daily": {"cap": 2020}}'
15. PRESENTED
BY
JSON in Redis
Type String Hash RedisJSON
Pros • Memory efficient
• Super fast in general
• Atomic field update
• Single key retrieval
(network efficient)
• Atomic field update
• Single key retrieval
(network efficient)
• Nested (full JSON support)
• Strongly typed
• Redis native
• No JSON <-> Hash convert
in client-side
Cons • Whole blob retrieval
(network is limited!)
• Non atomic JSON field
update
• Not nested (dictionary)
• JSON <-> Hash convert
in client-side
?????
17. PRESENTED
BY
• YCSB vs. redis-benchmark
• Benchmarking latency is not always fair
– Network bandwidth
– Disk (AOF, RDB, …)
– Client-side configs like connection pool (threads), pipelining, etc.
Caveats
18. PRESENTED
BY
Benchmark Redis
Get a JSON object
1.003
44.703
414.719
0.979 5.279
133.247
0.977 4.991
16.559
0
100
200
300
400
500
5 fields 1K fields 10K fields
95th Percentile Latency in millisecond
JSON.GET {key} . HGETALL {key} GET {key}
19. PRESENTED
BY
Benchmark Redis
Update a single field of JSON
0.988
40.063
301.055
0.984 4.067 9.2470.984 5.075 9.423
0
100
200
300
400
500
5 fields 1K fields 10K fields
95th Percentile Latency in millisecond
JSON.NUMINCRBY {key} .{field1}.{field2} {value}
HSET {key} {field} {value}
SET {key} {value}
22. PRESENTED
BY
• Go for RedisJSON if your {;} is small
– Know your workload
– Do benchmark
– Monitor Redis memory usage
Key Takeaways
When to use RedisJSON