comparative evaluation of the performance of in-memory key...

28
Comparative Evaluation of the Performance of In-Memory Key-Value Stores: Redis vs Memcached Department of Computer Science 04/02/2019 By Noshin Nawar Sadat and Ishank Jain

Upload: others

Post on 31-Aug-2019

2 views

Category:

Documents


0 download

TRANSCRIPT

Comparative Evaluation of the Performance of In-Memory Key-Value Stores: Redis vs Memcached

Department of Computer Science

04/02/2019

By Noshin Nawar Sadat and Ishank Jain

CONTENT

▪ Research Question

▪ Motivation

▪ Comparison

▪ Experiment

▪ Results

▪ Conclusion

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 2

RESEARCH QUESTION

• When you need to scale an application with a lot of data, how do you decide on a storage solution?

• How can you both safely store and efficiently interact with large data sets?

• Selecting the right Key-Value store is the question that comes up every time when we think to scale database driven application.

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 3

MOTIVATION

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 4

• Companies such as Facebook, Twitter, Reddit, and Pinterest have adopted Memcached, while Github, Airbnb, Snapchat, Flicker are among the companies

that use Redis.

• Many articles mention how Redis is better than Memcached because of all the different features it provides, but did not compare their performances.

REDIS

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 5

• Primary database for data that requires rapid processing.

• Redis can persist its data to disk and can be made highly available through in-

memory replication and auto-failover.

• All the commands in a transaction are

serialized and executed sequentially.

• Variety of expiration policy.

MEMCACHED

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 6

• Memcached organizes its memory in Slabs, this reduces the pain of

memory fragmentation.

• Items are made up of a key, an

expiration time, optional flags, and raw data.

• Servers are Disconnected From Each

Other.

• Least Recently Used cache.

Redis

▪ Redis is single threaded.

Memcached

▪ Memcached server is multi-threaded

▪ Memcached being multithreaded, can easily scale up by giving it more computational resources.

COMPARISON : SCALE UP

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 7

Redis

• Horizontally scale out available in Redis by clustering which is built-in.

• Cluster nodes have information about hash slots.

Memcached

• Horizontally scale out available by just adding new nodes.

• Cluster nodes have no information about hash slots

COMPARISON : SCALE OUT

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 8

Redis

• Redis provides consistency using a operation, which provides optimistic locking.

Memcached

• Uses Check and Set operation tomaintain strong consistency.

COMPARISON : CONSISTENCY

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 9

Redis

• Redis supports much richer data types, including String, Hash, List, Set and Sorted Set.

Memcached

• Memcached which only supports data records of the simple key-value structure

COMPARISON : SUPPORTED DATA TYPES

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 10

Redis

• Redis supports replication and persistence.

Memcached

• Memcached does not support replication and persistence. (sort of)

COMPARISON : OTHER FEATURES

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 11

BENCHMARKS: YCSB

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 12

• Yahoo! Cloud Serving Benchmark (YCSB) framework.

• Types of operations in workloads:

• Read

• Insert

• Update

• Scan

• The workloads can be customized. There can be following customizations:

• Number of operations

• Database size

• Operation ratios

• Number of clients

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 22

COMPARISON METRICS

▪ Latency (in µs)

▪ Read

▪ Update

▪ Insert

▪ Throughput (operations/second)

▪ Memory usage (in MB)

▪ Scaling out

▪ Single node vs three node cluster

▪ Number of concurrent clients: 1, 12, 24, 36, 48 (Threads)

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 13

MACHINES

▪ Server

▪ 15GB RAM

▪ 12 cores CPUs

▪ 1 Gbps ethernet link

▪ Client

▪ 7.76GB RAM

▪ 12 core CPUs

▪ 1 Gbps ethernet link

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 14

SYSTEM CONFIGURATION

▪ Redis

▪ Default configuration

▪ Disabled replication and persistence

▪ Memcached

▪ Default configuration

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 15

DATABASE

▪ Record size = 16 (fields) x 255 (bytes) = 4,080 bytes

▪ Total number of records = 2,500,000

▪ Total database size = 10.2 GB

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 16

WORKLOADS

Workloads Description Initial Database Size Number of operations

Workload A

(Balanced RU)50% Reads & 50% Updates 10.2 GB 2,500,000

Workload B

(Read-Heavy RU)95% Reads & 5% Updates 10.2 GB 2,500,000

Workload C

(Update-Heavy RU)5% Reads & 95% Updates 10.2 GB 2,500,000

Workload D

(Read-Heavy RI)90% Reads & 10% Inserts 5.1 GB 1,250,000

Workload E

(Insert-Heavy RI)10% Reads & 90% Inserts 5.1 GB 1,250,000

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 17

EXECUTING EXPERIMENT

Configure and start Redis/Memcached

in server(s)

Note down used memory by the

server(s)

Load data into the databases

Note down used memory by the

server(s)

Run a workload with Zipfian distribution

Note down used memory by the

server(s)

Latencies and throughputs are

stored automatically in client machine.

Clear Database

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 19

0

10000

20000

30000

40000

50000

60000

70000

1 12 24 36 48

Th

rou

gh

pu

t (o

ps/

s)

Number of Threads

Throughput for ClusterMemcached Redis

WORKLOAD A [50% Reads & 50% Updates]

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 20

0

200

400

600

800

1000

1200

1 12 24 36 48

Tim

e in

µs

Number of Threads

Update Latency for Single Node

Memcached Redis

0

200

400

600

800

1000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Update Latency for ClusterMemcached Redis

0

200

400

600

800

1000

1200

1 12 24 36 48

Tim

e in

µs

Number of Threads

Read Latency for Single NodeMemcached Redis

0

200

400

600

800

1000

1200

1 12 24 36 48

Tim

e in

µs

Number of Threads

Read Latency for ClusterMemcached Redis

0

10000

20000

30000

40000

50000

60000

70000

1 12 24 36 48

Th

rou

gh

pu

t (o

ps/

s)

Number of Threads

Throughput for Single NodeMemcached Redis

WORKLOAD B [95% Reads & 5% Updates]

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 16

0

500

1000

1500

2000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Update Latency for Single NodeMemcached Redis

0

500

1000

1500

2000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Update Latency for ClusterMemcached Redis

0

500

1000

1500

2000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Read Latency for Single NodeMemcached Redis

0

500

1000

1500

2000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Read Latency for ClusterMemcached Redis

0

10000

20000

30000

40000

50000

60000

70000

1 12 24 36 48

Th

rou

gh

pu

t (o

ps/

s)

Number of Threads

Throughput for Single NodeMemcached Redis

0

10000

20000

30000

40000

50000

60000

1 12 24 36 48

Th

rou

gh

pu

t (o

ps/

s)

Number of Threads

Throughput for ClusterMemcached Redis

WORKLOAD C [5% Reads & 95% Updates]

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 17

0

100

200

300

400

500

600

700

800

1 12 24 36 48

Tim

e in

µs

Number of Threads

Update Latency for Single NodeMemcached Redis

0

100

200

300

400

500

600

700

800

1 12 24 36 48

Tim

e in

µs

Number of Threads

Update Latency for ClusterMemcached Redis

0

100

200

300

400

500

600

700

1 12 24 36 48

Tim

e in

µs

Number of Threads

Read Latency for Single NodeMemcached Redis

0

100

200

300

400

500

600

700

800

1 12 24 36 48

Tim

e in

µs

Number of Threads

Read Latency for ClusterMemcached Redis

0

20000

40000

60000

80000

100000

1 12 24 36 48

Th

rou

gh

pu

t (o

ps/

s)

Number of Threads

Throughput for Single NodeMemcached Redis

0

20000

40000

60000

80000

100000

120000

140000

160000

1 12 24 36 48

Th

rou

gh

pu

t (o

ps/

s)

Number of Threads

Throughput for ClusterMemcached Redis

WORKLOAD D [90% Reads & 10% Inserts]

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 18

0

1000

2000

3000

4000

5000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Insert Latency for Single NodeMemcached Redis

0

1000

2000

3000

4000

5000

6000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Insert Latency for ClusterMemcached Redis

0

500

1000

1500

2000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Read Latency for Single NodeMemcached Redis

0

500

1000

1500

2000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Read Latency for ClusterMemcached Redis

0

5000

10000

15000

20000

25000

30000

35000

1 12 24 36 48

Th

rou

gh

pu

t (o

ps/

s)

Number of Threads

Throughput for Single NodeMemcached Redis

0

5000

10000

15000

20000

25000

30000

1 12 24 36 48

Th

rou

gh

pu

t (o

ps/

s)

Number of Threads

Throughput for ClusterMemcached Redis

WORKLOAD E [10% Reads & 90% Inserts]

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 19

0

500

1000

1500

2000

2500

3000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Insert Latency for Single NodeMemcached Redis

0

500

1000

1500

2000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Insert Latency for ClusterMemcached Redis

0

500

1000

1500

2000

2500

3000

1 12 24 36 48

Tim

e in

µs

Number of Threads

Read Latency for Single NodeMemcached Redis

0

500

1000

1500

2000

2500

1 12 24 36 48

Tim

e in

µs

Number of Threads

Read Latency for ClusterMemcached Redis

0

5000

10000

15000

20000

25000

30000

1 12 24 36 48

Th

rou

gh

pu

t (o

ps/

s)

Number of Threads

Throughput for Single NodeMemcached Redis

0

5000

10000

15000

20000

25000

30000

1 12 24 36 48

Th

rou

gh

pu

t (o

ps/

sec)

Number of Threads

Throughput for ClusterMemcached Redis

Memory Utilization

Scale

Memory Usage (in MB)

Memcached Redis

Single Node 10,876 14,740

3-Node Cluster 3,630 4958

PRESENTATION TITLE PAGE 20

Memcached requires 6.6% extra memory.Redis requires 44.5% extra memory!

Takeaways

WorkloadsLarge Number of Concurrent Clients Small Number of Concurrent Clients

Single Node Cluster Single Node Cluster

Workload A(50%R-50%U)

Memcached Memcached Memcached Memcached

Workload B(95%R-5%U)

Memcached Memcached Memcached Memcached

Workload C(5%R-95%U)

Redis Redis Redis Redis

Workload D(90%R-10%I)

Redis Redis Redis Redis

Workload E(10%R-90%I)

Redis Redis Memcached Memcached

PRESENTATION TITLE PAGE 21

If not much avaialble memory, use Memcached.

Further Exploration

▪ Comparison of their eviction policies.

▪ Performing multiple iterations of the test.

▪ Test cluster performances with increased database size.

PRESENTATION TITLE PAGE 22

Comparative Evaluation for the Performance of In-Memory Key-Value

Stores: Redis vs MemcachedPAGE 22