Lock Stores
InMemoryLockStore (default)
-
Description
InMemoryLockStoreis the default lock store. It maintains conversation locks within a single process.noteThis lock store should not be used when multiple Rasa servers are run in parallel.
-
Configuration
To use the
InMemoryTrackerStoreno configuration is needed.
ConcurrentRedisLockStore
ConcurrentRedisLockStore is a new, recommended lock store that uses Redis as a persistence layer and is safe for use with multiple Rasa server replicas.
See the migration section to learn how to switch to this lock store.
Description
The ConcurrentRedisLockStore uses Redis as a persistence layer for instances of issued tickets and the last issued ticket number.
The ticket number initialization begins at 1, in contrast to that of theRedisLockStore which begins at 0.
If the ticket expires, the ticket number will not be reassigned to future tickets; as a result ticket numbers are unique to ticket instances.
Ticket numbers are incremented using the Redis atomic transaction INCR on the persisted last issued ticket number.
The ConcurrentRedisLockStore ensures that only one Rasa instance can handle a conversation at any point in time.
Therefore, this Redis implementation of the LockStore can handle messages received in parallel for the same conversation by different Rasa servers
This is the recommended lock store for running a replicated set of Rasa servers.
High Availability Support
Redis high availability support is now available for the ConcurrentRedisLockStore.
You can now deploy with Redis Cluster for horizontal scaling or Redis Sentinel for automatic failover.
The ConcurrentRedisLockStore now supports Redis high availability deployments through Redis Cluster and
Redis Sentinel modes, enabling enterprise-grade scalability and reliability for production deployments.
The supported deployments are:
- Redis Cluster Mode: Provides horizontal scaling and is compatible with cloud-hosted Redis services.
- Redis Sentinel Mode: Offers high availability through automatic master/slave failover.
- Standard Mode: Maintains backward compatibility with existing single-instance deployments.
Configuration
To set up Rasa with Redis the following steps are required:
- Add required configuration to your
endpoints.yml:
- Rasa Pro <=3.7.x
- Rasa Pro >=3.8.x
lock_store:
type: rasa_plus.components.concurrent_lock_store.ConcurrentRedisLockStore
host: "host of the redis instance, e.g. localhost/"
port: "port of your redis instance, usually 6379/"
password: "password used for authentication"
db: "number of your database within redis, e.g. 0. Not used in cluster mode"
key_prefix: "alphanumeric value to prepend to lock store keys"
# high availability parameters introduced in 3.14 below
deployment_mode: "standard, cluster, or sentinel"
endpoints: "list of redis cluster/sentinel node addresses in the format host:port"
sentinel_service: "name of the redis sentinel service, only used in sentinel mode"
lock_store:
type: concurrent_redis
host: "host of the redis instance, e.g. localhost"
port: "port of your redis instance, usually 6379"
password: "password used for authentication"
db: "number of your database within redis, e.g. 0. Not used in cluster mode"
key_prefix: "alphanumeric value to prepend to lock store keys"
# high availability parameters introduced in 3.14 below
deployment_mode: "standard, cluster, or sentinel"
endpoints: "list of redis cluster/sentinel node addresses in the format host:port"
sentinel_service: "name of the redis sentinel service, only used in sentinel mode"
-
To start the Rasa server using your Redis backend, add the
--endpointsflag, e.g.:rasa run -m models --endpoints endpoints.yml
Configuration Parameters
url(default:localhost): The url of your redis instanceport(default:6379): The port which redis is running ondb(default:1): The number of your redis database. Ignored in cluster mode as Redis Cluster always uses database 0key_prefix(default:None): The prefix to prepend to lock store keys. Must be alphanumericpassword(default:None): Password used for authentication (Noneequals no authentication)use_ssl(default:False): Whether the communication is encryptedsocket_timeout(default:10): Time in seconds after which an error is raised if Redis doesn't answerdeployment_mode(default:standard): Deployment mode of Redis. One ofstandard,cluster, orsentinel.endpoints(default:None): List of Redis cluster node addresses in the formathost:port. Used for cluster and sentinel modes. For cluster mode, these are cluster node endpoints. For sentinel mode, these are sentinel instance endpoints.sentinel_service(default:mymaster): Name of the Redis sentinel service. Only used in sentinel mode.
Deployment Mode Details
- Standard Mode: Connects to a single Redis instance using url and port parameters.
- Cluster Mode: Connects to a Redis Cluster for horizontal scaling. If endpoints is not provided, falls back to auto-discovery using url and port.
- Sentinel Mode: Connects to Redis Sentinel for high availability with automatic master/slave failover.
Choosing a Deployment Mode
- Use standard mode for simple deployments with a single Redis instance.
- Use cluster mode for horizontal scaling and when using cloud Redis services that require cluster mode.
- Use sentinel mode for high availability with master/slave replication and automatic failover.