DEV Community

Juan Sedano
Juan Sedano

Posted on • Originally published at jsedano.dev on

Redis 2022

What is Redis (Remote Dictionary Server) on 2022. What can we do with it. How to scale. How to run it on the cloud.

What is Redis?

Redis is a key value store, just like a hash table. It can be used in-memory as cache and data will not be persisted or it can persist the data and be use as data storage. Keys can have a length to up to 512 MB.

It can also be used as a message queue / message broker.

Supported data types

Redis supports several data types

Type Max Size Description
Strings 512 MB Bytes, text, serialized objects, binary arrays
Lists 2^32 - 1 (4,294,967,295) elements. Linked list of Redis Strings
Sets 2^32 - 1 (4,294,967,295) members. Unordered unique Redis Strings
Sorted Sets Not specified Every String has also an integer weight that you must set up
Hashes 4,294,967,295 (2^32 - 1) field-value pairs Hash table
Streams Not specified Used to track real time events and allows consumers and consumer groups to read them

Special use cases types

Allows to store coordinates and perform operations such as finding the closest one.

Not gonna even try to summarize this one, read this instead.

Use a String like a bit vector, allows performing bitwise operations.

Allows storing, atomic read, write and read operations for 1 bit unsigned integers to 63 signed bit integers.

Additional support

RedisJSON

Adds facilities to store json documents and adds operations to be able to access / update fields using JSONPath.

RedisGraph

A graph database.

RedisTimeSeries

Module that adds a time series data structure to Redis, allowing querying by start / end time.

RedisBloom

Probabilistic data structures.

RedisInsight

Visual support that helps optimizing your stuff on Redis.

Message queues with Redis Pub/Sub

We can use Redis to create channels, send messages to the channels and have subscribers that recive the message.

Redis on the cloud

redis cloud

We can use a hosted service using the offer from Redis on Redis Cloud.

Or you can install it following guides detailed here.

aws

AWS only supports Redis as an in memmory database, but you could try to install it on a service like EC2 and put a separate storage to persist.

gcp

Google cloud platform currently does not suppert persisting the data out of the box.

azure

Apparently you can persist using out of the box redis services on azure, but they dont recomend it.

Scalabity

You can scale horizontally using Redis Cluster where you have a master that replicates the information between replicas, but it doesn’t guarantees that you are not going to lose data, if you are unlucky that a replica is randomly selected as master and then it goes down before propagating the changes, it can lose data, unless you configure it so that the master has to acknowledge having replicated the information, but then you have to accept a hit on your performance.

Security

Redis recomends that redis is only used on trusted environments where only trusted clients can access it.

Top comments (0)