Distributed locking environment variables
This reference documents environment variables that configure distributed locking behavior in the Application SDK. Distributed locking uses Redis to coordinate resource access across multiple workflow instances running on different nodes.
Locking control
These variables control whether the distributed locking system is active and how it retries lock acquisition when slots are occupied.
IS_LOCKING_DISABLED
booleanRequired
IS_LOCKING_DISABLED
booleanControls whether the distributed locking system is active. When true, activities with @needs_lock execute without coordination. When false, the system acquires locks before activity execution.
export IS_LOCKING_DISABLED=false
export IS_LOCKING_DISABLED=true
LOCK_RETRY_INTERVAL
integerOptional
LOCK_RETRY_INTERVAL
integerSeconds to wait between lock acquisition retry attempts. When all slots are occupied, the system waits this duration before randomly selecting another slot and retrying.
export LOCK_RETRY_INTERVAL=5
Redis connection
The Application SDK uses Redis to store and manage distributed locks. Configure your Redis connection using either standalone mode (single Redis instance) or Sentinel mode (high-availability cluster with automatic failover).
- Standalone mode
- Sentinel mode
Connect directly to a single Redis instance. Use this mode for development, testing, and small-scale deployments.
REDIS_HOST
stringRequired
REDIS_HOST
stringRedis server hostname or IP address.
export REDIS_HOST=localhost
export REDIS_HOST=redis.example.com
REDIS_PORT
integerOptional
REDIS_PORT
integerRedis server port number.
export REDIS_PORT=6379
REDIS_PASSWORD
stringOptional
REDIS_PASSWORD
stringAuthentication password for Redis connection. The SDK sends this password during the Redis AUTH command.
export REDIS_PASSWORD='your_password'
REDIS_DB
integerOptional
REDIS_DB
integerRedis database number for storing distributed lock keys. Redis supports databases 0-15 by default, providing logical keyspace separation.
export REDIS_DB=0
Connect to a Redis Sentinel cluster for automatic failover and high availability. Sentinel monitors Redis instances and promotes a replica to master if the current master fails.
REDIS_SENTINEL_HOSTS
stringRequired
REDIS_SENTINEL_HOSTS
stringComma-separated list of Sentinel host:port pairs. The system queries these Sentinel instances to discover the current Redis master node.
export REDIS_SENTINEL_HOSTS=sentinel1:26379,sentinel2:26379,sentinel3:26379
REDIS_SENTINEL_SERVICE
stringRequired
REDIS_SENTINEL_SERVICE
stringSentinel service name that identifies the Redis master instance. This matches the master name in your Sentinel configuration's monitor directive.
export REDIS_SENTINEL_SERVICE=mymaster
REDIS_PASSWORD
stringOptional
REDIS_PASSWORD
stringAuthentication password for Redis connection. The SDK sends this password during the Redis AUTH command.
export REDIS_PASSWORD='your_password'
REDIS_DB
integerOptional
REDIS_DB
integerRedis database number for storing distributed lock keys. Redis supports databases 0-15 by default, providing logical keyspace separation.
export REDIS_DB=0
See also
- Configure distributed locking: Step-by-step configuration guide
- Distributed locking: Understand how distributed locking works
- @needs_lock decorator: Decorator parameters and usage patterns
- Troubleshoot distributed locking: Common configuration issues