Configuring Distributed Backend Support

LightNap supports running multiple backend instances for scalability and high availability. When enabled, Redis is used for distributed caching and SignalR backplane.

Enabling Distributed Mode

To enable distributed mode:

  1. Set UseDistributedMode to true in the application settings.
  2. Configure the Redis connection string in the ConnectionStrings section:

    "ConnectionStrings": {
      "Redis": "your-redis-connection-string"
    }
    

What Distributed Mode Enables

When distributed mode is enabled, LightNap uses Redis for:

  • Distributed Caching: Shared cache across all instances for consistent data
  • SignalR Backplane: Real-time communication between instances for features like notifications
  • Distributed Locking: Coordination of database migrations and seeding across instances

Configuration Example

{
  "UseDistributedMode": true,
  "ConnectionStrings": {
    "Redis": "localhost:6379,password=mypassword,ssl=True,abortConnect=False"
  }
}

Deployment Considerations

Redis Setup

  • Use Azure Cache for Redis in production Azure deployments
  • Configure Redis with persistence for data durability
  • Set up Redis clustering for high availability
  • Use Redis authentication and SSL/TLS encryption

Instance Management

  • Ensure all instances use the same Redis instance
  • Configure load balancer sticky sessions if needed for SignalR
  • Monitor Redis connection health
  • Plan for Redis failover scenarios

Security

  • Use Redis authentication with strong passwords
  • Enable SSL/TLS for Redis connections
  • Restrict Redis access to application servers only
  • Regularly rotate Redis access keys

Best Practices

  • Test distributed mode thoroughly before production deployment
  • Monitor Redis performance and memory usage
  • Implement proper Redis backup and recovery procedures
  • Use Redis connection pooling to optimize resource usage
  • Consider Redis persistence options based on your data requirements