redis overview

32
REDIS OVERVIEW Dinh Hoang Long Framgia, Inc.

Upload: hoang-long

Post on 13-Jul-2015

205 views

Category:

Technology


0 download

TRANSCRIPT

REDIS OVERVIEW

Dinh Hoang LongFramgia, Inc.

2

Outline

● NoSQL and Redis● The Creation of Redis● Redis Features● Redis Persistence

3

NoSQL

● Non-relational● Distributed● Open-source● Horizontally scalable

4

Redis

Key Value Store NoSQL DBMS

5

The Creation of Redis

6

The Creation of Redis

The story of Salvatore Sanfilippo (antirez)

Creator of Redis

7

Business

● Receiving a stream of page views from multiple websites.

● Storing the latest n page views for every site

● Show latest page views in real time to users

● Maintaining history

8

Problem

With a peak load of a few thousand page views per second

● Whatever the database schema was

● Whatever trade-offs is

→ No way for storing by SQL

9

The Creation of Redis

Solution● In-memory data store

● Storing lists as a native data type

● Implementing using C language

● Adding fork-based persistence feature

10

The Creation of Redis

Solution● In-memory data store

● Storing lists as a native data type

● Implementing using C language

● Adding fork-based persistence feature

→ Finally, Redis was born!

11

Redis Features

● Data Model● Master/Slave Replication● In-memory

12

Data Model

● STRING

13

Data Model

● STRING● LIST

14

Data Model

● STRING● LIST● SET

15

Data Model

● STRING● LIST● SET● HASH

16

Data Model

● STRING● LIST● SET● HASH● ZSET (Sorted Set)

17

Master/Slave Replication

Source: http://harish11g.blogspot.com

18

In-memory

FAST

19

What happened if server is turned off?

20

Redis Persistence

21

Redis Persistence

Storing data in hard disk● RDB (Redis Database)● AOF (Append Only File)

22

RDB (Redis Database)

23

RDB (Redis Database)

Point-in-time snapshots of dataset at specified intervals.

24

RDB (Redis Database)

Advantages● Perfect for backup and transfer● Maximum performance

- Child process: Persist on disk

- Parent process: No I/O

25

RDB (Redis Database)

Disadvantages● Cannot minimize the chance of data loss● fork() can be time consuming if the dataset is big

26

AOF (Append Only File)

27

AOF (Append Only File)

● Logs every write operation received by the server● Plays again operation at server startup to reconstruct

the original dataset

28

AOF (Append Only File)

Advantages● Durability (sync every second, every query)● No seek is required● Automatically rewrite AOF in background when it

gets too big

29

AOF (Append Only File)

Disadvantages● Files are usually bigger than RDB files.● Can be slower than RDB● Rare bugs in specific commands

30

What should we use?

31

References

T NG QUAN V REDIS Ổ Ề http://tech.blog.framgia.com/vn/?p=3365

@dinhhoanglong91

32

Thank for watching!