Gaming

Redis Labs on GCP

Agenda

  1. Redis Overview and Use Cases

  2. Redis Demo

  3. Redis Enterprise

  4. Google Cloud and Redis Enterprise

  5. Google Cloud Demo

redis logo white
Figure 1. The leading in-memory database platform
redislabs
Figure 2. Open-source home and commercial provider of Redis Enterprise technology and services

Performance

  • Optimized architecture

  • Advanced processing

  • Efficient client/server interaction

Benchmark

benchmark performance
Figure 3. Benchmark performed by Avalon Consulting Group

Benchmark

benchmark infra
Figure 4. Benchmark published in the Google blog

Simplicity

data structures
Figure 5. Data Structures

Extensibility

modules
Figure 6. Modules

What can you do with Redis?

  • Cache

  • Messaging

  • User Sessions

  • Real-time Recommendation Engine

  • Leaderboards

  • … and much more

webarch
Figure 7. Modern Web App
webarch redis
Figure 8. Modern Web App with Redis

Simple Cache

The Problem

Multiple database calls create impossibly slow web page response times

Why Redis Rocks

  • Strings store text or binary

  • SET lets you store any payload

  • GET to retrieve values

  • Optional expiration

  • Listen for changes on keys and expirations

  • Multiple eviction policies supported

User Session

The problem

  • Maintain session state across multiple servers

  • Multiple session variables

  • High speed/low latency required

Why Redis rocks

  • Hashes store session variables as key/value pairs

  • HMSET to store key/value pairs

  • HMGET to retrieve values

  • HINCRBY to increment a field within the hash

  • HDEL to delete one key/value

HMSET session:1 user 8754 name dave ip 10:20:104:31 hits 1
HMGET session:1 user name ip hits
+------+--------------+
| user |     8754     |
+------+--------------+
| name |     dave     |
+------+--------------+
|  ip  | 10.20.104.31 |
+------+--------------+
| hits |      1       |
+------+--------------+
HINCRBY session:1 hits 1
+------+--------------+
| user |     8754     |
+------+--------------+
| name |     dave     |
+------+--------------+
|  ip  | 10.20.104.31 |
+------+--------------+
| hits |      2       |
+------+--------------+
HSET session:1 last home
+------+--------------+
| user |     8754     |
+------+--------------+
| name |     dave     |
+------+--------------+
|  ip  | 10.20.104.31 |
+------+--------------+
| hits |      2       |
+------+--------------+
| last |     home     |
+------+--------------+
HGET session:1 lastpage  (1)
HDEL session:1 lastpage  (2)
DEL session:1  (3)
  1. Get lastpage field from hash

  2. Delete lastpage entry from hash

  3. Delete the whole hash

Work Queues

The problem

  • Tasks need to be worked on asynchronously

  • Lots of items to be worked on

  • Assign items to worker and remove from queue

  • Similar to buffering high speed data-ingestion

  • High speed/low latency required

Why Redis rocks

  • Lists are perfect for this

  • LPUSH/RPUSH add values at head or tail

  • RPOPLPUSH: pop from queue, push to another

LPUSH queue:1 red
       +-------------+-------------+-------------+-------------+-------------+
queue∶1|cRED red     |             |             |             |             |
       +-------------+-------------+-------------+-------------+-------------+
LPUSH queue:1 green
       +-------------+-------------+-------------+-------------+-------------+
queue∶1|cGREgreen    |cRED red     |             |             |             |
       +-------------+-------------+-------------+-------------+-------------+
RPUSH queue:1 blue
       +-------------+-------------+-------------+-------------+-------------+
queue∶1|cGREgreen    |cRED red     |             |             |cBLU blue    |
       +-------------+-------------+-------------+-------------+-------------+
RPOPLPUSH queue:1 queue:2
       +-------------+-------------+-------------+-------------+-------------+
queue∶1|cGREgreen    |cRED red     |             |             |             |
       +-------------+-------------+-------------+-------------+-------------+
                                                                      |
               +------------------------------------------------------+
               |
               v
       +-------------+-------------+-------------+-------------+-------------+
queue∶2|cBLU blue    |             |             |             |             |
       +-------------+-------------+-------------+-------------+-------------+

Leaderboard

The problem

  • Many users playing a game or collecting points

  • Display real-time leaderboard

  • Who is your nearest competition

  • Disk-based DB is too slow

Why Redis rocks

  • Sorted sets automatically keep sorted list of users

  • ZADD to add/update

  • ZRANGE, ZREVRANGE to get user

  • ZRANK will get any user’s rank instantaneously

ZADD game:1 10000 id:1
ZADD game:1 21000 id:2
ZADD game:1 34000 id:3
ZADD game:1 35000 id:4
+------+-------+
| id∶4 | 35000 |
+------+-------+
| id∶3 | 34000 |
+------+-------+
| id∶2 | 21000 |
+------+-------+
| id∶1 | 10000 |
+------+-------+
ZINCRBY game:1 10000 id:3
+------+-------+
| id∶3 | 44000 |<-+
+------+-------+  |
| id∶4 | 35000 |--+
+------+-------+
| id∶2 | 21000 |
+------+-------+
| id∶1 | 10000 |
+------+-------+

Leaderboard

ZREVRANGE game:1 0 0  (1)
ZREVRANGE game:1 0 3 WITHSCORES  (2)
  1. Get the top player

  2. Get the top 3 players with their scores

Messaging

The problem

  • Devices send data to multiple services

  • Apps send out events to multiple users

pubsub
Figure 9. Streams
streams scenario1
Figure 10. Scenario 1
streams scenario2
Figure 11. Scenario 2
streams scenario3
Figure 12. Scenario 3
streams scenario4
Figure 13. Scenario 4

Redis Demo

Redis Enterprise

Redis Enterprise

Redis Enterprise Advantages

advantages

Redis Enterprise Node

redis enterprise cluster components

Redis Enterprise Cluster

cluster

Active/Active Geo Distribution

crdb

Redis on Flash

rlec flash slider

Google Cloud

google cloud
  • Fully-managed Redis Enterprise

  • Integrated billing

Google Cloud Demo

Google Cloud Workloads

  • Multi-model:

    • RediSearch

    • RedisGraph

    • RedisTimeSeries

  • Hyper-scale: Redis on Flash

Developer-First Experience

  • Google Cloud: built for new gen of enterprise software

  • Redis: “Most Loved Database” on Stack Overflow for 3 years running

Low Latency

  • Google Cloud: low latency network

  • Redis Enterprise delivers sub-ms latency

Emphasis on Open Source

  • Google Cloud committed to OSS with expanded partnerships at NEXT

  • Redis has largest global OSS community of any NoSQL database

Benefits for Gaming

Player Engagement

  • Curate social media

  • Power real-time leaderboards & rating systems

  • Enable online chat

Caching

  • Improve game responsiveness

  • Reduce need to access legacy databases

  • Ensure real-time content

High-speed transactions

  • High speed data processing

  • Fast, predictable sub-millisecond performance

  • Linear scalability: 50M ops/sec @ <1 ms latency

Real-time game analytics

  • User session data

  • In-game risk analysis

Personalized game offers

  • Process high volumes of in-game data

  • Personalized session data

  • Player notifications

Cost savings

  • Manage large datasets with Redis on Flash

  • 70% infra cost savings using tiered memory

Thank You