At the Redis Labs workshop I had this week in Copenhagen, we had technical deep dive on Redis and Redis Enterprise. It’s great that Redis Labs made a ready-for-use docker images that we can pull and Redis instances we can SSH right away. Cool way to do workshops. I have know Redis for while I have yet to get practical experience on it, probably I’ve been drowned into data and backend services far too long already :).
Here’s some of the basics:
- Redis is REmote DIctionary Server. You must be creating hash tables, value key-pairs and tuples C#, let’s make them distributed with Redis.
- Redis is a data store, a distributed memory-persistent data store. Because its memory-native, it’s very fast and because it’s distributed, you can scale out to multiple machines to host your data and take advantage of full processing power each node.
- Redis is for low-latency high throughput data flow. Here, I Iike the water pipe analogy. Latency is the average time required for water to travel from one end to other end of the pipe. Throughput is the amount of water that gets in/out of the pipe. In our world, water is data, and if we have better pipe (RAM) we get same amount of data for smaller amount of time.
- Redis is a key-value NoSQL data store. So, sorry you can’t pull data by SQL query. Move on sql-b***h!. That’s me!
- Redis is orginally created by Salvatorre Sanflippo and he made it open source. Good call master!
- Redis is #1 in NoSQL database in docker hub with 630+million pulls and rated “most loved database” in 2018 Stackoverflow survey.
- Redis is fast, but it’s not the fastest NoSQL datastore. A position have yet to claim.
Let’s me share some more bits:
- Redis is the OSS, Redis Labs is company who maintain Redis, Redis Enterprise is a forked out version with enterprise features. Seem’s like a trend nowadays. Like RH Linux and RH Enterprise, or Elastic Search and Elastic.co.
- Redis is in-memory but it can support durability. Durability = Disk. Or if you’re purist and really would like to go all-in with memory, you can provision a cluster so you can prevent complete rebuild in in case of catastrophic failure. You probably wouldn’t want to rebuild entire database from scratch right?
- Redis is scalable and can be made highly-available. You can scale out by adding new nodes and sharding your data. Clusters, Nodes and Shards are the “buzzwords” today so make sure you’re on top of this.
- Because Redis is OSS, you can also get managed enterprise instances from other vendors. We have Azure Redis Cache, Amazon ElastiCache or maybe create your own Redis fork.
Another strenghts of Redis is its modules and large community all trying to make Redis better. For full list of modules visit https://redis.io/modules.
- Rate Limiter
Redis is competing with these NoSQL databases:
- Apache Cassandra
- Apache Kafka
In general, Redis can be used in the follow cases:
- High-speed caching
- Session & state management
- Real-time analytics
- Message queuing via pub/sub
- Real-time data injestor/buffer
I’m more interested in real-world practical cases so I short-listed those I find to be most relevant to me:
- As staging datastore in website. Redis can serve as middle database between web front end and RDMS backend. In this architecture, you get performance benefit of in-memory cache and data accessibility + ACID-ty of RDMBS.
- As full page cache. Redis holds all your website pages and index them. For example, when your user asks for TellMeMoreAboutYourservice.html, you always pickup from memory and not from disk. Redis can also invalidate pages if you need some TTL capability.
- As message queue. Redis serves as pub/sub platform. For example, when customer adds item into shopping cart, you may want to do handfull of things. Maybe, update session information, update site counters, reserve the sku, calculate total, taxes and discounts. We can queue this activities and let customer continue his shopping. Eventually, these actions will be executed when she checks out.
- As buffer or data injestor to ELK. When I say ELK,I actually mean Logstash. Redis can serve as buffer pool to Logstash so you can handle some event spikes. These event spikes could bug down the ES indexer and potentially blocking other logs.
- For complete list, please refer to my references section. I find 99% of the cases are for improving the web and mobile experience.
Who are the general audience of Redis? Developers. To me this just made Redis a NO to machine learning. IMO, I would like our data scientists to focus on crunching data and building models rather than understanding how to pull out and project data in useful structure.
The Redis Manifesto is to reduce complexity. True enough, it tries to do as little as possible so your execution is fast but actually it just pushes back the complexity to the application or data users.
Kafka just introduced KSQL, will Redis follow through? So far No. I have asked this to Redis Labs and they have no immediate plans.
When do you go with Redis Enterprise
- When you reached the limits of your network and you need the “**ties” in your instances. These are high-availability, geo-redundancy, security etc.
- When Disaster Recovery is a primary driver.
- When governance dropped the axes and demands an Enterprise SLA.
Future: Redis Streams
Redis is taking on Kafka and it’s going to be exciting. Today, we would like to receive data as close to real-time as possible and we should be able to correlate data as they arrive in real-time. The process is called Windowing. This is already offered by Kafka Stream and Spark Streaming. But these streaming systems are disk-based and lot more complex and costly to operate. My first deep dive with Kafka wasn’t very pleasant. F** the zookeeper.
Redis Streams is pub/sub platform with snapshot support; just like kafka. Redis Labs says its not in GA, it will be soon. Most likely, it will be included in Redis 5 release.
Redis Use Cases
http://highscalability.com/blog/2011/7/6/11-common-web-use-cases-solved-in-redis.html http://www.paperplanes.de/2010/2/16/a_collection_of_redis_use_cases.html https://redislabs.com/wp-content/uploads/2016/03/15-Reasons-Caching-is-best-with-Redis-RedisLabs-1.pdf https://redislabs.com/docs/forrester-wave-translytical-data-platforms-q4-2017/ https://backbase.com/resources/forrester-wave-2017-digital-banking-report/?utm_source=google&utm_medium=cpc&utm_campaign=eu_forrester&gclid=Cj0KCQjwkpfWBRDZARIsAAfeXaoxJKrpuHTeyNJq88TQhVwXD0LHY_MMMMS9nKza0w0c-Ni8sZz-K64aApIMEALw_wcB
Redis Performance review
Redis Implementation Matrix
Redis Enterprise by Redis Labs
Azure Redis Cache by Microsoft
https://azure.microsoft.com/en-us/services/cache/ https://docs.microsoft.com/en-us/azure/redis-cache/ https://azure.microsoft.com/en-us/resources/videos/azure-redis-cache-101-introduction-to-redis/
Elasticache by Amazon