To address the issue of inconsistent visibility of supervisor processes and cached data across your application servers, you need to ensure that all servers are correctly configured to use the same Redis instance and that there are no network or configuration issues causing the separation. Here are some steps to troubleshoot and resolve the problem:
-
Check Redis Configuration: Ensure that all your application servers are pointing to the same Redis host and port. Verify the configuration in your
config/database.phpandconfig/cache.phpfiles.// config/database.php 'redis' => [ 'client' => env('REDIS_CLIENT', 'phpredis'), 'default' => [ 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => env('REDIS_DB', 0), ], ], // config/cache.php 'stores' => [ 'redis' => [ 'driver' => 'redis', 'connection' => 'default', ], ],Ensure that the
.envfile on each server has the correct Redis host and port:REDIS_HOST=your_redis_host REDIS_PORT=6379 -
Network Connectivity: Verify that all application servers can connect to the Redis server. You can use tools like
telnetorredis-clito test connectivity.telnet your_redis_host 6379Or using
redis-cli:redis-cli -h your_redis_host -p 6379 pingYou should receive a
PONGresponse if the connection is successful. -
Horizon Configuration: Ensure that Horizon is correctly configured to use the same Redis connection on all servers. Check your
config/horizon.phpfile.'use' => 'default',Also, ensure that the Horizon configuration in the
.envfile is consistent across all servers. -
Supervisor Configuration: Ensure that the Supervisor configuration files are correctly set up on each server. Each server should have a unique identifier for its Horizon processes. You can set this in the
horizon.phpconfiguration file:'environments' => [ 'production' => [ 'supervisor-1' => [ 'connection' => 'redis', 'queue' => ['default'], 'balance' => 'auto', 'processes' => 10, 'tries' => 3, ], ], ],Ensure that each server has a unique supervisor name (e.g.,
supervisor-1,supervisor-2, etc.). -
Cache and Session Configuration: Ensure that the cache and session configurations are consistent across all servers. Check
config/session.phpandconfig/cache.php.// config/session.php 'driver' => env('SESSION_DRIVER', 'redis'), // config/cache.php 'default' => env('CACHE_DRIVER', 'redis'), -
Clear Cache: Clear the application cache and config cache on all servers to ensure that there are no stale configurations.
php artisan config:cache php artisan cache:clear php artisan horizon:terminate -
Check Redis Persistence: Ensure that Redis persistence is correctly configured to avoid data loss. Check your Redis configuration file (
redis.conf) forappendonlyandsavedirectives.appendonly yes save 900 1 save 300 10 save 60 10000
By following these steps, you should be able to ensure that all your application servers are correctly configured to use the central Redis host and that all data for cache, sessions, and queues is available across all servers. If the problem persists, consider checking for any network issues or Redis server performance issues that might be causing the separation.