Redis Streams- Introduction
What does REDIS stand for?
Re mote Di ctionary S erver
What is are Redis Streams and what advantages do this feature offer?
Redis is a data store also called, “open source in-memory key value data store”, with which you can simply and rapidly get your data. This is because Redis has many data structures to meet many application requirements individually.
Unlike hard disk storage or SSD, in-memory data storage avoids delays in search times due to the versatile data structures.
Redis Streams stores the data in perpetuity and therefore the data can be accessed at any time. Redis finds application e.g., in databases, cache, MesssageMessage Broker and others.
The response times are remarkable, because with a time of less than one millisecond a request can be evaluated on millions of stored keys.
The simplicity and user friendliness of Redis is backed demonstrated by an easy to use API, enables by the fact that fewer code characters need to be written to perform read or /write operations in few lines of code. In addition, more than one hundred open-source clients are available to developers, such as Java, C++, Python, PHP and many more.
Redis CLI example:
SET key "Hello" GET key
Redis can also be operated as a cluster. In this case, requests are distributed across multiple servers, which optimizes read performance. Highly available solutions can be achieved with the primary replication architects, enabling consistent performance and reliability. In addition, many horizontal and vertical scaling options are available if you need to adjust the cluster size.
In addition, extensibility is also a major benefit, as vendor or technology dependency does not exist, as the data store is based on open standards and supports custom data formats, as well as having numerous clients.
In application with KENBUN’s voice assistant KIDOU we use a new data type “STREAMS” which was inserted fromintroduced in Redis 5.0 and which supports data streams. In an abstract way, a protocol data structure is modeled, and performance-aware operations are provided on it.
Redis-Streams allows the consumer to wait for new data added by the producer in the stream. The data in a stream is persisted and available even after a consumer has read it. Additionally, there is a concept called “Consumer Groups”. Consumer Groups are used when multiple consumers are listening to a stream, but each message on the stream should only be processed by one consumer.
Redis CLI example:
# write data on a stream XADD mystream * sensor-id 1234 temperature 19.8 # read all the data from the stream XRANGE mystream - +
Cosumer Groups were originally introduced by the popular messaging system Kafka (TM). Redis implements a similar idea in a slightly different way but the goal is the same: to allow a group of clients to collaborate and consume a different part of the same message stream.
In our YouTube video “Introduction to Redis Streams:
Differences to Pub/Sub, Performance and Live Code Example” you will learn what possibilities and advantages the new feature brings.
• Studium Elektrotechnik, Uni Stuttgart
• Promotion in Robotik, KIT: Deep Learning Methoden zum autonomen Greifen von unbekannten Objekten
• AI Engineer: Transfer von wissenschaftlichen Methoden in die Industrie
Dr. Simon Ottenhaus studied electrical engineering at the University of Stuttgart and received his PhD in robotics from KIT on autonomous grasping of unknown objects using deep learning methods. At KENBUN IT AG he works on the transfer of machine learning methods from research to industry, especially speech assistants in an industrial context.