Skip to content

owenthereal/RedisSortingSpike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RedisSortingSpike

A spike to investigate the performance of sorting and paging with Redis.

Requirement

  • Redis 2.8.x
  • Maven

Running Test

$ mvn test

Size of testing data

The goal is to being able to sort and paginate 1,000,000 entities in Redis with reasonable performance.

Approach 1: set and SORT

Approach 1 stores IDs in a set and use sort for sorting and paging. This approach uses less memory (328MB) but is quite slow (30.24s). The slowness comes from sorting 1 million records in memory. The test is here.

Approach 2: sorted set

Approach 2 builds and stores indexes in a sorted set for each entity field. This approach uses more memory (484MB with selected fields) but is super fast (0.03s). The extra memory consumption comes from storing indexes for each entity field. The test is here.

Conclusion

Approach 2 will use almost double the memory as approach 1 in production but it offers excellent latency that end users will expect This is a typical example of space-time tradeoff. In production, Redis can be used as an LRU cache so that memory consumption is under control.

About

A spike to investigate the performance of sorting and paging with Redis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages