Top Banner
Mathias Meyer, 22.10.2009 Peritor GmbH Redis - Fast and Furious NSQL Berlin Donnerstag, 22. Oktober 2009
49

Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Mar 17, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Mathias Meyer, 22.10.2009Peritor GmbH

Redis - Fast and FuriousN✮SQL Berlin

Donnerstag, 22. Oktober 2009

Page 2: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Self

I work at Peritor in Berlin

I tweet @roidrage

I code at http://github.com/mattmatt

I blog at http://paperplanes.de

2

Donnerstag, 22. Oktober 2009

Page 3: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Peritor

Working on

http://scalarium.com

3

Donnerstag, 22. Oktober 2009

Page 4: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis - Key-Value Store

Simple, yet awesome

Fast, yet nonvolatile

code.google.com/p/redis

4

Donnerstag, 22. Oktober 2009

Page 5: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis

REmote DIctionary Server

5

Donnerstag, 22. Oktober 2009

Page 6: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis

Went public in March 2009

Just reached 1.0

6

Donnerstag, 22. Oktober 2009

Page 7: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis

< 6000 lines of code

7

Donnerstag, 22. Oktober 2009

Page 8: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis

And the code is simple

8

Donnerstag, 22. Oktober 2009

Page 9: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis

No threading, just one process

9

Donnerstag, 22. Oktober 2009

Page 10: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis

Like Memcached, only awesome

10

Donnerstag, 22. Oktober 2009

Page 11: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis

Simple and efficient text-based protocol

(just like grandma and Memcached used to make)

11

Donnerstag, 22. Oktober 2009

Page 12: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol

12

Donnerstag, 22. Oktober 2009

Page 13: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol

13

redis[“key”] = “value”

Donnerstag, 22. Oktober 2009

Page 14: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol

Duh!

14

Donnerstag, 22. Oktober 2009

Page 15: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol

Values can be strings, lists or sets

15

Donnerstag, 22. Oktober 2009

Page 16: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol - Special Ops

Push and pop elements (atomic)

Fetch arbitrary set and array elements

Sorting

16

Donnerstag, 22. Oktober 2009

Page 17: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol

set foo 4

1000

+OK

17

Donnerstag, 22. Oktober 2009

Page 18: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol

set foo 4

1000

+OK

17

Request

Response

Donnerstag, 22. Oktober 2009

Page 19: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol

get foo

$4

1000

get bar

$-1

18

Donnerstag, 22. Oktober 2009

Page 20: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol

get foo

$4

1000

get bar

$-1

18

Request

Response

RequestResponse

Donnerstag, 22. Oktober 2009

Page 21: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol

incr foo

:1001

type foo

+string

19

Donnerstag, 22. Oktober 2009

Page 22: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol - Lists

lpush pizza 4

fury

+OK

rpush pizza 8

ortolana

+OK

20

Donnerstag, 22. Oktober 2009

Page 23: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol - Lists

lrange pizza 0 1

*2

$4

fury

$8

ortolana

21

Donnerstag, 22. Oktober 2009

Page 24: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol - Lists

lrange pizza 0 1

*2

$4

fury

$8

ortolana

21

Request

Response

Donnerstag, 22. Oktober 2009

Page 25: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol - Sets

sadd mq 8

rabbitmq

:1

sadd mq 6

zeromq

:1

22

Donnerstag, 22. Oktober 2009

Page 26: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol - Sets

smembers mq

*2

$6

zeromq

$8

rabbitmq

23

Donnerstag, 22. Oktober 2009

Page 27: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol - Sets

sort mq alpha

*2

$8

rabbitmq

$6

zeromq

24

Donnerstag, 22. Oktober 2009

Page 28: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Protocol - The Rest

Random list/set access

Intersections, Unions

Monitoring

Controlling the Server

Multi-Set Commands

25

Donnerstag, 22. Oktober 2009

Page 29: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis

Data is held in memory, but can be persisted

26

Donnerstag, 22. Oktober 2009

Page 30: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Key-Value Database

Persistent

Asynchronous

Just like Super Pursuit Mode

27

Donnerstag, 22. Oktober 2009

Page 31: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Database

Data is written to disk asynchronously

28

Donnerstag, 22. Oktober 2009

Page 32: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Database

29

Redis Server

Redis Serverfork()

Dump Database

exit()

rename()

Donnerstag, 22. Oktober 2009

Page 33: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Database

save 900 1

save 300 10

save 60 100000

30

Donnerstag, 22. Oktober 2009

Page 34: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Replication

1 Master - N Slaves

Asynchronous on Master

Synchronous on Slave

31

Donnerstag, 22. Oktober 2009

Page 35: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis ReplicationLike dumping the database, only to a different file descriptor.

32

Donnerstag, 22. Oktober 2009

Page 36: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Master

Redis Slave Redis Slave

Redis SlaveRedis Slave

Redis Replication

33

Donnerstag, 22. Oktober 2009

Page 37: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis - Scaling

Horizontal• Run multiple Redis processes

• Use HashRing (e.g. in redis-rb)

34

Donnerstag, 22. Oktober 2009

Page 38: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis - Scaling

Vertical• Master-Slave setup

• Fetch data from any slave (e.g. random)

35

Donnerstag, 22. Oktober 2009

Page 39: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

To Redis, or not to Redis?

36

Donnerstag, 22. Oktober 2009

Page 40: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

As always, it depends

37

Donnerstag, 22. Oktober 2009

Page 41: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

To Redis

38

CachingStatistical dataRecoverable stateWorker queue

Donnerstag, 22. Oktober 2009

Page 42: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Not to Redis

100% consistent dataset requiredData is larger than memory

39

Donnerstag, 22. Oktober 2009

Page 43: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis Use Cases

Nanite - A self-assembling cluster of Ruby daemons

40

Donnerstag, 22. Oktober 2009

Page 44: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

The most important question!

41

Donnerstag, 22. Oktober 2009

Page 45: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Is it faster than Memcached?

42

Donnerstag, 22. Oktober 2009

Page 46: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

No, but fast enough for you(if you need the extra features)

43

Donnerstag, 22. Oktober 2009

Page 47: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Redis

44

Simple, fast, awesome.

Donnerstag, 22. Oktober 2009

Page 48: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

Questions?

45

Donnerstag, 22. Oktober 2009

Page 49: Redis - Fast and Furiousnosqlberlin.de/slides/NoSQLBerlin-Redis.pdf · 2009-11-01 · Redis - Fast and Furious N ... Redis Protocol - The Rest Random list/set access Intersections,

© Peritor GmbH - Alle Rechte Vorbehalten

Peritor GmbHBlücherstr. 22, Hof III Aufgang 610961 Berlin

Tel.: +49 (0)30 69 20 09 84 0Fax: +49 (0)30 69 20 09 84 9

Internet: www.peritor.comE-Mail: [email protected]

Donnerstag, 22. Oktober 2009