Redis 2022
Tags: redis
Published: 2022-09-17 19:01:04

---
title: Redis 2022
published: true
date: 2022-09-17 06:00:00 UTC
tags: redis,redis
canonical_url: https://jsedano.dev/redis/2022/09/17/redis-2022.html
---

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](https://redis.io/docs/data-types/tutorial/#keys) can have a length to up to 512 MB.

It can also be used as a [message queue / message broker.](https://redis.com/solutions/use-cases/messaging/)

## Supported data types

Redis supports several data types

| Type | Max Size | Description |
| --- | --- | --- |
| [Strings](https://redis.io/docs/data-types/tutorial/#strings) | 512 MB | Bytes, text, serialized objects, binary arrays |
| [Lists](https://redis.io/docs/data-types/lists/) | 2^32 - 1 (4,294,967,295) elements. | Linked list of Redis Strings |
| [Sets](https://redis.io/docs/data-types/sets/) | 2^32 - 1 (4,294,967,295) members. | Unordered unique Redis Strings |
| [Sorted Sets](https://redis.io/docs/data-types/sorted-sets/) | Not specified | Every String has also an integer weight that you must set up |
| [Hashes](https://redis.io/docs/data-types/hashes/) | 4,294,967,295 (2^32 - 1) field-value pairs | Hash table |
| [Streams](https://redis.io/docs/data-types/streams/) | Not specified | Used to track real time events and allows consumers and consumer groups to read them |

### Special use cases types

- [Geospatial](https://redis.io/docs/data-types/geospatial/)

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

- [HyperLogLog](https://redis.io/docs/data-types/geospatial/)

Not gonna even try to summarize this one, [read this instead.](http://antirez.com/news/75)

- [Bitmaps](https://redis.io/docs/data-types/geospatial/)

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

- [Bitfields](https://redis.io/docs/data-types/geospatial/)

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

## Additional support

### [RedisJSON](https://redis.io/docs/stack/json/)

Adds facilities to store json documents and adds operations to be able to access / update fields using [JSONPath](https://goessner.net/articles/JsonPath/).

### [RedisGraph](https://redis.io/docs/stack/graph/)

A graph database.

### [RedisTimeSeries](https://redis.io/docs/stack/timeseries/)

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

### [RedisBloom](https://redis.io/docs/stack/bloom/)

Probabilistic data structures.

### [RedisInsight](https://redis.io/docs/stack/insight/)

Visual support that helps optimizing your stuff on Redis.

## [Message queues with Redis Pub/Sub](https://redis.io/docs/manual/pubsub/)

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](https://redis.com/try-free/).

Or you can install it following [guides detailed here.](https://developer.redis.com/create/from-source/)

### [aws](https://aws.amazon.com/redis/)

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](https://cloud.google.com/memorystore/docs/redis/redis-overview)

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

### [azure](https://azure.microsoft.com/en-us/products/cache/)

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](https://redis.io/docs/manual/scaling/) 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](https://redis.io/docs/manual/security/)

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