Configure distributed locking
Set up Redis and environment configuration to enable distributed locking in your Atlan applications.
Configure Redis connection and environment settings to enable distributed locking coordination across your Atlan application workflow instances.
Prerequisites
- Redis server (standalone or Sentinel cluster)
- For Sentinel mode:
- Minimum 3 sentinel instances for quorum-based decisions
- Sentinel instances on separate hosts from Redis instances
- Network connectivity between all sentinel and Redis instances
- Firewall configuration for sentinel communication ports
- For Sentinel mode:
- Access to your application's
.envfile - Network connectivity between your application and Redis server
Enable distributed locking
Distributed locking is disabled by default. Enable it by setting the required environment variables in your application's .env file:
-
Enable the locking system:
# Enable distributed locking (disabled by default)export IS_LOCKING_DISABLED=false -
Configure lock retry behavior:
# Seconds between lock acquisition attempts (default: 5)export LOCK_RETRY_INTERVAL=5
Configure Redis connection
Distributed locking uses Redis for coordination across workflow instances. Configure your Redis connection based on whether you're using standalone Redis or a Sentinel cluster for high availability.
- Sentinel mode (production)
- Standalone mode (development)
# Redis Sentinel configuration
export IS_LOCKING_DISABLED=false
export REDIS_SENTINEL_HOSTS=sentinel1.example.com:26379,sentinel2.example.com:26379,sentinel3.example.com:26379
export REDIS_SENTINEL_SERVICE=mymaster
export REDIS_PASSWORD=your_secure_password
export REDIS_DB=0
# Basic Redis connection
export IS_LOCKING_DISABLED=false
export REDIS_HOST=redis.example.com
export REDIS_PORT=6379
export REDIS_PASSWORD=your_secure_password
export REDIS_DB=0
Set environment-specific configuration
Your configuration settings differ between development and production environments. Use the appropriate configuration for your deployment context.
- Production
- Development
# Always enable locking in production
export IS_LOCKING_DISABLED=false
# Use Sentinel for high availability
export REDIS_SENTINEL_HOSTS=sentinel1:26379,sentinel2:26379,sentinel3:26379
export REDIS_SENTINEL_SERVICE=mymaster
export REDIS_PASSWORD=production_password
# Configure retry behavior
export LOCK_RETRY_INTERVAL=5
For local development and testing:
# Disable locking for faster development iteration
export IS_LOCKING_DISABLED=true
# Or enable with local Redis
export IS_LOCKING_DISABLED=false
export REDIS_HOST=localhost
export REDIS_PORT=6379
# No password required for local development
Verify configuration
After completing the configuration, verify that your application can successfully connect to Redis:
# Test basic connectivity
redis-cli -h $REDIS_HOST -p $REDIS_PORT ping
# Test with authentication
redis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_PASSWORD ping
Expected output:
PONG
See also
- Distributed locking: Understand how distributed locking coordinates resource access
- Environment variables: Complete environment variables reference