Skip to main content

Documentation Index

Fetch the complete documentation index at: https://arivu.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Overview

For production environments where horizontal scaling is required, use Redis as your Arivu memory backend.

Pros ✅

  • Distributed architecture - Share state across multiple workers
  • High performance - In-memory data store with microsecond latency
  • Scalable - Handles high concurrency efficiently
  • Cluster support - Redis cluster for fault tolerance
  • Session sharing - Multiple instances can access the same sessions
  • Requires external service - Must run a Redis server
  • Data persistence overhead - Requires configuration for durability
  • Memory constraints - Limited by available RAM

Configuration

Redis must be installed and running before Arivu can connect to it. Choose a setup method below:
1

Set Environment Variables

Add these to your .env file:
MEMORY_BACKEND=redis
REDIS_URL=redis://localhost:6379/0
2

Verify Connection

Test your Redis connection:
redis-cli ping
# Should respond with: PONG
3

Initialize Arivu

Start using Redis in your Python code:
from arivu.memory import RedisBackend, SessionStore

backend = RedisBackend(redis_url="redis://localhost:6379/0")
store = SessionStore(backend=backend)

Connection String Format

redis://[user:password@]host:port[/db-number]
redis://localhost:6379/0

Performance Optimization

Connection Pooling

RedisBackend automatically handles connection pooling, so you don’t need to configure it manually.
Configure RDB or AOF to ensure your data survives Redis restarts:
# In redis.conf
save 900 1          # Save if 1 key changed in 900 seconds
appendonly yes      # Enable AOF persistence
Redis stores everything in RAM. Monitor memory usage to prevent out-of-memory errors.
  • Set a max memory policy: maxmemory-policy allkeys-lru
  • Monitor with redis-cli INFO memory
  • Clean up old sessions regularly
For high availability, use Redis Cluster:
redis-cli cluster create node1:6379 node2:6379 node3:6379 \
  node4:6379 node5:6379 node6:6379

Production Deployment

REDIS_URL=redis://redis-master:6379/0
MEMORY_BACKEND=redis

When to Use Redis

Use Redis when you:
  • Need to scale horizontally (multiple workers)
  • Require high performance and low latency
  • Want to share sessions across services
  • Are deploying to production
  • Need fault tolerance and failover
Redis is ideal for microservices architectures where multiple Arivu instances need to share session state.

Monitoring & Troubleshooting

Test your Redis connection:
# Check if Redis is responding
redis-cli ping
# Should respond with: PONG

# Check connected clients
redis-cli INFO clients

# Monitor memory usage
redis-cli INFO memory

# Check database size
redis-cli DBSIZE
Problem: Cannot connect to RedisSolutions:
  • Ensure Redis server is running: redis-cli ping
  • Check connection string is correct
  • Verify firewall rules allow the port
  • Check credentials if using authentication
Problem: Redis consuming too much memorySolutions:
  • Review session retention policies
  • Clear old sessions: redis-cli FLUSHALL (use with caution)
  • Set max memory limit: maxmemory 2gb in config
  • Monitor with redis-cli INFO memory
Problem: Slow session operationsSolutions:
  • Check Redis response times: redis-cli --latency
  • Verify network connectivity
  • Consider Redis clustering for high load
  • Monitor with redis-cli --stat