# Redis-HA

## Overview

The source code and default configuration of the Building Block is available in our [code.syseleven.de](<https://code.syseleven.de/syseleven/building-blocks/helmfiles/redis-ha/-/blob/main/README.md>). Infos on release notes and new features please follow [Release notes redis-ha](<https://code.syseleven.de/syseleven/building-blocks/helmfiles/redis-ha/-/blob/main/RELEASE-NOTES.md>)

### Redis-HA

Redis is a widely used in memory data store which can be used as a database. It belongs to NoSQL Databases and fits to use cases where a simple data structures fit.

### Prerequisites On Redis-HA

Proceed with the following prerequisite description to use the Building Block out of the box.

#### Recommended Setup

A recommended resource overview is listed in the table below.

| CPU / vCPU | Memory |
| --- | --- |
| 1.3 | 1380 + 128-256MiB per worker node |

No further activities need to be carried out in advance.

### Redis Architecture

Redis consists of 5 Pods:

- 2 x HAProxy
- 3 x Redis HA Server

### Adding The Building Block

Add the directory `syseleven-redis-ha` to your control repository. Add a `.gitlab-ci.yml` to the directory with the following content:

```yaml
include:
  - project: syseleven/building-blocks/helmfiles/redis-ha
    file: JobDevelopment.yaml
    ref: { { site.building_blocks.redis_ha.version|e } }
  - project: syseleven/building-blocks/helmfiles/redis-ha
    file: JobStaging.yaml
    ref: { { site.building_blocks.redis_ha.version|e } }
  - project: syseleven/building-blocks/helmfiles/redis-ha
    file: JobProduction.yaml
    ref: { { site.building_blocks.redis_ha.version|e } }
```

Remove environments you are not using by removing their include.

### Configuration

#### Redis maxmemory/pod Limits Config Option

For a production-grade setup, it is highly recommended to define a maxmemory limit for Redis and resource limit for the pod. In our experience the formula `maxmemory * 125% <= limits` can be used for a stable configuration.

`syseleven-redis-ha/values-redis-ha.yaml`

```yaml
redis:
  config:
    maxmemory: 1024MB
  resources:
    limits:
      memory: 1280Mi
```

### Monitoring

#### Additional Alert-Rules

- [Redis](<https://code.syseleven.de/syseleven/building-blocks/helmfiles/redis-ha/-/blob/main/redis-ha-extension/templates/redis-prometheusrule.yaml>)
- Cluster
- Memory
- Connections
- [HAProxy](<https://code.syseleven.de/syseleven/building-blocks/helmfiles/redis-ha/-/blob/main/redis-ha-extension/templates/haproxy-prometheusrule.yaml>)
- Cluster
- Connections to redis
- Connections in general

#### Additional Grafana dashboards

- Redis
- An overview of performance metrics of Redis (for example memory usage, clients, hits/misses, total items, ...)
- HAProxy
- An overview of performance metrics of HAProxy (for example connections, sessions, queues, ...)

### Redis

- Amount of replicas can be adjusted
- Requests/limits for CPU/memory can be adjusted

### HAProxy

- Amount of replicas can be adjusted
- Requests/limits for CPU/memory can be adjusted

### Scaling Setup

This building block consists of multiple components. Each of the components can and must be scaled individually.

### Release-Notes

Please find more infos on release notes and new features [release notes Redis-HA](<https://code.syseleven.de/syseleven/building-blocks/helmfiles/redis-ha/-/blob/main/RELEASE-NOTES.md>)
