Skip to main content
By default, AgentLauncher tracks sessions in local memory. This works for single-node deployments, but breaks when you scale horizontally — each node only knows about its own sessions. The SessionRegistry with a RedisSessionKVStore solves this by sharing session state across all nodes via Redis. Any node can query or close sessions running on any other node, and sticky sessions are no longer required.

Why Multi-Node?

  • Scalability — Handle more concurrent voice sessions by distributing across nodes
  • Reliability — If one node goes down, new sessions route to healthy nodes
  • Session visibility — Any node can query or close sessions running on any other node

Installation

This installs redis[hiredis] as an optional dependency.

Quick Start

Without a registry, AgentLauncher falls back to an in-memory store automatically. Existing single-node deployments continue to work with no changes.

How It Works

  1. Registration — When start_session() is called, the session is registered in the store with a TTL (default 30s)
  2. Heartbeat — The maintenance loop periodically refreshes the TTL for all active sessions on this node, keeping them alive in the store
  3. Cross-node close — Calling the close endpoint on any node writes a close-request flag to the store. The node owning that session picks it up during the next maintenance cycle and shuts it down
  4. Expiry — If a node crashes, its sessions’ TTLs expire naturally. Other nodes see those sessions disappear from the registry
The ttl value must be significantly higher than maintenance_interval to avoid sessions expiring between heartbeats. The default of 30s TTL with 5s maintenance interval provides a comfortable margin.

Architecture

The system has three layers:
  1. SessionKVStore — Abstract key-value store with TTL support. Two built-in implementations:
    • InMemorySessionKVStore — Used by default for single-node deployments
    • RedisSessionKVStore — For multi-node production deployments
  2. SessionRegistry — Facade that manages session lifecycle: registration, heartbeat refresh, cross-node close requests, and expiry detection
  3. AgentLauncher — Accepts an optional registry parameter. When provided, the maintenance loop refreshes TTLs and processes close requests from other nodes

Configuration

SessionRegistry

RedisSessionKVStore

Either client or url must be provided. Pass client to reuse an existing Redis connection pool, or url for convenience.

InMemorySessionKVStore

Used automatically when no store is provided. Suitable for single-node deployments and development.

Custom Store Backend

The SessionKVStore is an abstract class with a simple interface. You can implement your own backend for any key-value store that supports TTL-based expiry (DynamoDB, Memcached, etcd, etc.). Subclass SessionKVStore and implement these abstract methods:
Then pass it to SessionRegistry:
The store works with raw bytes — all serialization is handled by SessionRegistry. Your implementation only needs to store and retrieve byte values with TTL expiry.

Next Steps

Docker Deployment

Docker, Kubernetes, and scaling basics

Built-in HTTP Server

HTTP server API reference and configuration

Telemetry & Metrics

Monitor agent performance in production

Deploy Example

Complete Helm chart implementation