Skip to main content

Configure distributed locking

TL;DR

Set up Redis and environment configuration to enable distributed locking in your Atlan applications.

Connect

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
  • Access to your application's .env file
  • 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:

  1. Enable the locking system:

    # Enable distributed locking (disabled by default)
    export IS_LOCKING_DISABLED=false
  2. 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.

# 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

Set environment-specific configuration

Your configuration settings differ between development and production environments. Use the appropriate configuration for your deployment context.

# 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

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