redis-service
Go to file
Berkay 4e4dbf60ea two host redis implemented 2025-12-06 17:19:02 +03:00
two-host two host redis implemented 2025-12-06 17:19:02 +03:00
.env proxmox redis server added 2025-04-19 21:21:04 +03:00
.env.example proxmox redis server added 2025-04-19 21:21:04 +03:00
.python-version test python added 2025-04-19 21:36:45 +03:00
README.md test python added 2025-04-19 21:36:45 +03:00
docker-compose.yml insight added 2025-04-29 14:54:19 +03:00
hello.py test python added 2025-04-19 21:36:45 +03:00
proxmox-lxc-setup.md updated yml 2025-04-19 21:32:49 +03:00
pyproject.toml test python added 2025-04-19 21:36:45 +03:00
redis_load_test.py test python added 2025-04-19 21:36:45 +03:00
redis_test.log test python added 2025-04-19 21:36:45 +03:00
requirements.txt updated yml 2025-04-19 21:32:49 +03:00
uv.lock test python added 2025-04-19 21:36:45 +03:00

README.md

Redis Service for LXC Container

This repository contains a production-ready Docker Compose configuration for running a Redis server in an LXC container on Proxmox.

Overview

This setup provides:

  • Redis server with password authentication
  • Data persistence using AOF (Append Only File)
  • Automatic container restart
  • Health checks
  • Volume management for data persistence

Prerequisites

  • LXC container configured for Docker (as described in the Proxmox setup guide)
  • Docker and Docker Compose installed on the LXC container
  • Network connectivity from the container

Configuration

The service is configured using environment variables defined in the .env file:

Variable Description Default
REDIS_VERSION Redis Docker image version 7.0.12
REDIS_PASSWORD Password for Redis authentication Must be set
REDIS_PORT Port mapping for Redis 6379
TIMEZONE Container timezone UTC

Installation

  1. Clone this repository to your LXC container:

    mkdir -p /opt/redis-service
    cd /opt/redis-service
    # Clone your repository or copy files manually
    
  2. Create a proper .env file with secure credentials:

    cp .env.example .env
    nano .env
    

    Make sure to set a strong password for REDIS_PASSWORD.

  3. Start the Redis service:

    docker-compose up -d
    
  4. Verify that the container is running:

    docker-compose ps
    

Data Persistence

Redis data is stored in a Docker volume named redis-data. This ensures that your data persists even if the container is restarted or recreated.

The Redis server is configured with AOF (Append Only File) persistence using the --appendonly yes option, which provides better durability for your data.

Connecting to Redis

To connect to your Redis server from another container or service:

redis-cli -h <container-ip> -p 6379 -a <your-redis-password>

For applications using the Redis server, use the following connection string:

redis://:your_redis_password@redis-server:6379/0

Maintenance

Viewing Logs

docker-compose logs redis

Backing Up Redis Data

# Create a backup directory
mkdir -p /opt/redis-backups

# Run the backup command
docker exec redis-server redis-cli -a your_redis_password SAVE
docker cp redis-server:/data/dump.rdb /opt/redis-backups/redis-backup-$(date +%Y%m%d%H%M%S).rdb

Updating Redis

To update the Redis version, modify the REDIS_VERSION in your .env file and restart the service:

docker-compose down
docker-compose up -d

Security Considerations

  • The Redis server is password-protected
  • Only expose the Redis port if necessary
  • Consider using a firewall to restrict access to the Redis port
  • For production environments, consider implementing additional security measures like network isolation

Performance Test Results

The repository includes a Python script (redis_load_test.py) for load testing the Redis server with 100 concurrent threads. Below are sample test results:

===== TEST SUMMARY =====

Operation: CREATE
Total operations: 10000
Successful operations: 10000
Failed operations: 0
Duration: 3.33 seconds
Operations per second: 3001.43

Operation: UPDATE
Total operations: 10000
Successful operations: 10000
Failed operations: 0
Duration: 4.15 seconds
Operations per second: 2408.91

Operation: DELETE
Total operations: 10000
Successful operations: 10000
Failed operations: 0
Duration: 1.29 seconds
Operations per second: 7771.63
=========================

These results demonstrate the Redis server's performance capabilities:

  • Create operations: ~3,000 ops/sec
  • Update operations: ~2,400 ops/sec
  • Delete operations: ~7,700 ops/sec

To run the performance test yourself:

python redis_load_test.py