RedisGears Redis in memory data processing JUNE 2019 | PIETER - - PowerPoint PPT Presentation

redisgears redis in memory data processing
SMART_READER_LITE
LIVE PREVIEW

RedisGears Redis in memory data processing JUNE 2019 | PIETER - - PowerPoint PPT Presentation

RedisGears Redis in memory data processing JUNE 2019 | PIETER CAILLIAU About me Produced in Belgium (instanceof) SE @ TomTom Consultant @ neo4j Solution Architect @ Redis Labs Product Manager @ Redis Labs @cailliaup


slide-1
SLIDE 1

RedisGears – Redis in memory data processing

JUNE 2019 | PIETER CAILLIAU

slide-2
SLIDE 2
  • Produced in Belgium
  • (instanceof) SE @ TomTom
  • Consultant @ neo4j
  • Solution Architect @ Redis Labs
  • Product Manager @ Redis Labs
  • @cailliaup

About me

2

slide-3
SLIDE 3

1

What is Redis and Redis Enterprise

2

Stream Processing with RedisGears

3

RedisGears as a Multimodel Engine

Agenda

slide-4
SLIDE 4

4

Redis is Fast …

slide-5
SLIDE 5

5

… Extremely Fast

slide-6
SLIDE 6

DB-Engines Ranking

6

slide-7
SLIDE 7

7

And you’ve been using it already

slide-8
SLIDE 8

Redis is Extensively and Diversely Used

8 Uses Redis for: Timeline, following Scope: 10-20 TB Uses Redis for: Local/site/global caching Uses Redis for: Repository router Scope: 10+ TB Uses Redis for: Geo search, user profiles Scope: 10-20 TB Uses Redis for: All messages Scope: 40 TB

slide-9
SLIDE 9

Redis Top Differentiators Simplicity Extensibility Performance

NoSQL Benchmark

1

Redis Data Structures

2 3

Redis Modules 9

Lists Hashes Bitmaps Strings Bit field Streams Hyperloglog Sorted Sets Sets Geospatial Indexes

slide-10
SLIDE 10

10

✓ Written in C ✓ Served entirely from memory ✓ Single-threaded, lock free ✓ Most commands are executed with O(1) complexity ✓ Access to discrete elements within objects ✓ Reduced bandwidth/

  • verhead requirements

✓ Easy to parse networking protocol ✓ Pipelining for reduced network overhead ✓ Connection pooling

OPTIMIZED ARCHITECTURE ADVANCED PROCESSING EFFICIENT OPERATION

Redis Speed differentiators

slide-11
SLIDE 11

11

✓ Written in C ✓ Served entirely from memory ✓ Single-threaded, lock free ✓ Most commands are executed with O(1) complexity ✓ Access to discrete elements within objects ✓ Reduced bandwidth/

  • verhead requirements

✓ Easy to parse networking protocol ✓ Pipelining for reduced network overhead ✓ Connection pooling

OPTIMIZED ARCHITECTURE ADVANCED PROCESSING EFFICIENT OPERATION

Redis Speed differentiators

slide-12
SLIDE 12
  • Create your own data types and commands
  • Reuse Redis’ simplicity, performance, scalability and high

availability.

  • Can be written in C/C++/Go/Python/Rust/Zig
  • Leverage existing data structures
  • Turn Redis into a Multi-Model database

Modules Extend Redis Infinitely

12

https://redislabs.com/community/redis-modules-hub/

slide-13
SLIDE 13

RediSearch (GA) redisearch.io RedisBloom (GA) redisbloom.io RedisTimeSeries redistimeseries.io RedisJSON (GA) redisjson.io RedisAI redisai.io RedisGraph (GA) redisgraph.io

Redis Modules

13

slide-14
SLIDE 14

14

Introducing

slide-15
SLIDE 15

Redis Enterprise

15

DBaaS

  • Available since mid 2013
  • 8,500+ enterprise customers

Software

  • Available since early 2015
  • 300+ enterprise customers

550K+ databases managed worldwide

  • 6 of top Fortune 10 companies
  • 3 of top 5 communications companies

Customers

  • 3 of top 4 credit card issuers
  • 3 of top 5 healthcare companies
slide-16
SLIDE 16
  • Cloud Provider
  • Higher margin by

– Idleness

  • Cloud Lock-in

Cloud Providers have different incentives

16

  • DBAAS Provider
  • Higher margin by better resource

utilization

– Multi-tenancy – Reducing RAM – CPU utilization

slide-17
SLIDE 17

Redis Enterprise : A Unique Primary Database

HIGHEST PERFORMANCE, LINEAR SCALING HIGH AVAILABILITY WITH INSTANT 
 FAILOVER DURABILITY AT MEMORY SPEEDS ACTIVE-ACTIVE GEO DISTRIBUTION

(CRDT-BASED)

BUILT-IN HIGH PERFORMANCE
 SEARCH MULTI-MODEL FLEXIBLE DEPLOYMENT OPTIONS

(CLOUD, ON-PREM, HYBRID)

INTELLIGENT TIERED DATA ACCESS

(RAM & FLASH MEMORY)

FAST RELIABLE FLEXIBLE

slide-18
SLIDE 18

Redis Enterprise Cluster

Node 1 Node 2 Node N (odd number)

18

Uneven number of symmetric nodes

slide-19
SLIDE 19

Redis Enterprise Cluster

Node 1 Node 2 Node N (odd number)

19

Single master database

M

slide-20
SLIDE 20

Redis Enterprise Cluster

Node 1 Node 2 Node N (odd number)

20

An HA database

S M

slide-21
SLIDE 21

Redis Enterprise Cluster

Node 1 Node 2 Node N (odd number)

21

A Clustered Database

M1 M2 M3

slide-22
SLIDE 22

How do keys get assigned to partitions?

22

slide-23
SLIDE 23

How do keys get assigned to partitions?

23

slide-24
SLIDE 24

Redis Enterprise Cluster

Node 1 Node 2 Node N (odd number)

24

A Highly Available Clustered Database

M1 M2 M3 S3 S1 S2

slide-25
SLIDE 25

Redis Enterprise Node

25

Cluster Manager

Enterprise Layer Open Source Layer

REST API Zero latency proxy Redis Shards

slide-26
SLIDE 26

Redis Enterprise: Shared Nothing Symmetric Architecture

Cluster Management Path Node Watchdog Cluster Watchdog Node 1 Node 2 Node N (odd number) Redis Shards
 & Proxies Data Path

26

Data-Path and Control/Management Path Separation

slide-27
SLIDE 27

27

as a datagrid

slide-28
SLIDE 28

Microservices Architecture and Polyglot Persistence

28 Authentication Authentication Authentication

Key/Value

K V

Key/Value

K V

Key/Value

K V

Customers

Key/Value

K V

Graph

Customers

Key/Value

K V

Graph

Catalog

RDBMS Cache

Search Session Store Session Store Session Store

Document Document Document

API API API API API API API API API

Fraud Detection

API

Columnar Search

Fulfilment

API

RDBMS

slide-29
SLIDE 29

The Cost of Polyglot Persistence

Authentication Authentication Authentication

Key/Value

K V

Key/Value

K V

Key/Value

K V

Customers

Key/Value

K V

Graph

Customers

Key/Value

K V

Graph

Catalog

RDBMS Cache

Search Session Store Session Store Session Store

Document Document Document

API API API API API API API API API

Fraud Detection

API

Columnar Search

Fulfilment

API

RDBMS

Increased application complexity Costly communication

Application does heavy lifting in sharing data, keeping data sets in sync

High operational burden Higher cost of ownership

Different databases have specialized administrative, scaling, availability requirements

Sub-optimal Resource Usage Higher cost

Dedicating pods/servers for each type of database reduces deployment efficiency

slide-30
SLIDE 30

API API API API API API API

Redis Enterprise: A Multi-model Database for Microservices

Authentication Customers Catalog Search Fraud Detection Session Store

Search Graph Key/Value RDBMS Key/Value Cache RDBMS Cache

Fulfilment

Key/Value Document

slide-31
SLIDE 31

Authentication Customers Catalog Search Fraud Detection Session Store

Search Graph Key/Value RDBMS Key/Value Cache RDBMS Cache

Fulfilment

Key/Value Document

Built-in Message Broker

Built-in Pub-Sub / Streams for event synch across data stores

slide-32
SLIDE 32

What are we missing?

  • How to consume messages in this “built in message borker”
  • Given a sharded database, how can I run analytical queries?
  • Multi Model database

– Single copy in core datatypes – Inter module communication – Component X doing translations between modules.

slide-33
SLIDE 33

33

RedisGears Introducing

slide-34
SLIDE 34

RedisGears is a Serverless engine for multi-model and cluster operations in Redis, supporting both event driven as well as batch operations

What is RedisGears?

slide-35
SLIDE 35

GearsCoordinator MapReducer GearsExecuter Gears infrastructure is written in C C - API

Soon Soon

High Performance Architecture

slide-36
SLIDE 36

RedisGears allows to define a pipe of operations

  • Returning value from one operation is passed to the next operation in the pipe
  • Last operation returning the result to the user
  • First operation is called ‘reader’ - responsible for providing data

– Keys reader - read keys from Redis – Stream reader - read streams from Redis – Python reader - allow to user to write his own readers in python

Scripting with RedisGears

36

slide-37
SLIDE 37
  • Map
  • FlatMap
  • Filter
  • Groupby + Reduce
  • Aggregate
  • Sort
  • Limit
  • ForEach
  • Distinct

Supported Operations

37

slide-38
SLIDE 38

Reader (Flat) Mapper

Using RedisGears – (Flat)Mapping

slide-39
SLIDE 39

Using RedisGears - Filtering

Reader

Filter record with 1 doc

slide-40
SLIDE 40

Using RedisGears - Aggregate

Reader

Count Aggregator

1 1

slide-41
SLIDE 41

Demo

slide-42
SLIDE 42

Gears has a streaming API to allow to trigger gears execution on events.

– Redis Stream events - Trigger an execution whenever a new data enters a steam – Redis Keys events - Trigger an operation whenever a key is touched

Use Case #1 – Stream Processing

RedisTimeSeries Redis Streams Every sec

slide-43
SLIDE 43

Because of RedisGears’ flexibility (it's actually running python) you can achieve internal module integration with it:

– Read from hashes and index in RediSearch/RedisGraph – Read RedisJSON data and pass to RedisTimeSeries – …

Use Case #2 – a MultiModel Engine

RediSearch Redis Hashes Every update RedisGraph

slide-44
SLIDE 44

# create the builder

builder = GearsBuilder()

# filter events on key:'all_keys'

builder.filter(lambda x: x['key'] != 'all_keys')

# add the keys to 'all_keys' set

builder.map(lambda x: execute('sadd', 'all_keys', x['key']))

# register the execution on key space notification

builder.register() 
 
 Build a gear that creates maintains a set of all keys within redis

Recipe #1 – even triggering

slide-45
SLIDE 45

# create the pipe builder. KeysOnlyReader is a performance improvement only piping the keys.

builder = GearsBuilder('KeysOnlyReader')

# get from each hash the genres field

builder.map(lambda x: execute('hget', x, 'genres'))

# filter those who do not have genres

builder.filter(lambda x: x is not None)

# split genres by comma

builder.flatmap(lambda x: x.split(','))

# count for each genre the number of times it appears

builder.countby()

# start the execution

builder.run('movie:*') Build a gear that counts how often a genre is used within a set of movies

Recipe #2 – map reducing

slide-46
SLIDE 46

# create the builder with a StreamReader

builder = GearsBuilder('StreamReader')

# extract each field value pair from the message and increase the pipe granularity

builder.flatmap(lambda x: [(a[0], a[1]) for a in x.items()])

# filter out the streamId itself

builder.filter(lambda x: x[0] != 'streamId')

# make sure the gears data lives in the correct shard

builder.repartition(lambda x: x[0])

# apply each field value pair to a key

builder.foreach(lambda x: execute('set', x[0], x[1]))

# register on new messages on the stream 'inputStream'

builder.register('inputStream') Build a gear that consumes a stream and updates keys accordingly

Recipe #3 – stream processing

slide-47
SLIDE 47

Example Trigger Explained

47

slide-48
SLIDE 48

Example Trigger Explained

48

slide-49
SLIDE 49

Example Trigger Explained

49

slide-50
SLIDE 50

Example Trigger Explained - Flatmap

50

slide-51
SLIDE 51

Example Trigger Explained - Repartition

51

slide-52
SLIDE 52

Example Trigger Explained - executeCommand

52

slide-53
SLIDE 53

Demo

slide-54
SLIDE 54

Demo Setup

54

slide-55
SLIDE 55
  • https://github.com/RedisGears/AnimalRecognitionDemo
  • #redisfoundmycat

Challenge?

55

slide-56
SLIDE 56

RediSearch (GA) redisearch.io RedisBloom (GA) redisbloom.io RedisTimeSeries redistimeseries.io RedisJSON (GA) redisjson.io RedisAI redisai.io RedisGraph (GA) redisgraph.io

Redis Modules

56

RedisGears redisgears.io

slide-57
SLIDE 57

Thank you!


pieter@redislabs.com

57