Skip to content

Databases

Senren currently supports three high-performance in-memory databases for caching and feature stores.

Supported Databases

Redis

The most popular in-memory data structure store.

Use cases: - Caching - Session storage - Simple feature stores - Real-time leaderboards

Configuration:

from senren import Database

redis = Database(
    name="user-cache",
    type="redis",
    memory_mb=512,
    regions=["aws:us-east-1"],
)

Characteristics: - Single-node deployment - Simple, fast - Suitable for small-to-medium datasets

Redis Cluster

Distributed Redis with automatic sharding.

Use cases: - Large-scale feature stores - High-throughput caching - Multi-GB datasets - High availability requirements

Configuration:

redis_cluster = Database(
    name="feature-store",
    type="redis-cluster",
    memory_mb=8192,
    regions=["aws:us-east-1", "gcp:us-central1"],
)

Characteristics: - Automatic sharding across nodes - Higher throughput than single Redis - Built-in replication

Dragonfly DB

High-performance, Redis-compatible database with superior resource efficiency.

Use cases: - Feature stores requiring high throughput - Cost-sensitive deployments (better memory efficiency) - Modern Redis replacement

Configuration:

dragonfly = Database(
    name="features",
    type="dragonfly",
    memory_mb=4096,
    regions=["aws:us-east-1"],
)

Characteristics: - 25x faster than Redis in benchmarks - Better memory efficiency - Redis API compatibility - Multi-threaded architecture

Multi-region Deployment

Deploy the same database to multiple regions:

from senren import SenrenClient, Database

client = SenrenClient(endpoint="control.senren.dev")

# Same feature store in 3 regions
client.apply_state(
    databases=[
        Database(
            name="user-features",
            type="redis-cluster",
            memory_mb=8192,
            regions=[
                "aws:us-east-1",
                "aws:eu-west-1",
                "gcp:asia-east1",
            ],
        )
    ]
)

Important: Each regional deployment is independent. Senren does not automatically replicate data between regions. You're responsible for data consistency if needed.

Configuration Options

All databases support these options:

Database(
    name="my-db",           # Unique name within namespace
    type="redis-cluster",   # redis | redis-cluster | dragonfly
    memory_mb=4096,         # Memory allocation
    regions=[...],          # List of cloud:region identifiers
    namespace="prod",       # Kubernetes namespace (optional, default: "default")
)

Querying Status

Check if a database is ready:

status = client.get_status("user-features")

if status.ready:
    print(f"Database ready at {status.host}:{status.port}")
else:
    print("Database is provisioning...")

Connecting to Databases

Once provisioned, connect using standard Redis clients:

Python:

import redis

r = redis.Redis(host=status.host, port=status.port)
r.set("key", "value")

Node.js:

const redis = require('redis');
const client = redis.createClient({
  host: status.host,
  port: status.port
});

Resource Sizing

Memory recommendations:

Use Case Type Memory
Session cache redis 512 MB - 2 GB
Feature store (small) redis-cluster 2 GB - 8 GB
Feature store (large) redis-cluster 8 GB - 64 GB
High-throughput cache dragonfly 4 GB - 32 GB

Pro tip: Start small and scale up based on actual usage.

Coming Soon

  • Aerospike: Hybrid memory/SSD database
  • PostgreSQL: Managed relational databases
  • Cassandra: Wide-column store

See the roadmap for details.