Imagine that you want to follow the sell price of a stock over a period of six months, or perhaps you want to track the actions of a video game player in that same time frame. For use cases like this, you would likely want to use a time series database to store and analyze your data — and Redis is the ideal resource. Since its creation, Redis has been used for storing and analyzing time series data, and it is equipped with the ability to perform advanced analysis.
With Redis, you can tackle a variety of time series use cases, ranging from IoT sensor data to order values from online retailers. The most efficient and flexible way to gather and assess time series data in Redis combines two different structures: the Sorted Set and the Hash. Every entry in a Sorted Set is a combination of a double “score” and a string “member,” with the former acting as the sorted value in the tree and the latter acting as a key in the hash. By combining Sorted Sets and Hashes in this way, you can access members and scores directly by member or score value.
Storing time series data like this in Redis is one of the database’s most popular uses, and it facilitates everything from social networks to news sites. And with Redis, you have numerous options for analyzing time series data. For example, you can use ZCOUNT to count the number of events that took place during a certain time period, or ZRANGE4 to scan the newest or oldest event IDs. In fact, you can even implement your time series analysis as a Lua script. Download our white paper now to learn more about the time series analysis options offered by Redis.
The appeal of Redis does not lie solely within its ability to take on a diverse range of use cases. Redis is also the ideal time series analysis solution because it constantly evaluates and remedies performance issues, and its commands and Lua scripting yield high performance and flexibility. Not only that, but also Redis is able to store and retrieve data at extremely rapid rates. Redis stores everything in RAM and in optimized data structures, which renders it three orders of magnitude faster than SSD-backed databases.
It is true that the queries and operations available in Redis are restricted based on the types used to store data, but Redis remains flexible in that it also uses bitmaps, array indexed byte strings, HyperLogLogs, Lists, Sets and Geo commands when studying and providing analytics. If you want to get a better understanding of how Redis can be used as a time series database, please download our white paper.