I have 2 EC2 instances - on one is the production app, on the other one is Redis. I connect from the first one to Redis.
This is how I set Sidekiq:
Sidekiq.configure_server do |config|
config.redis = { url: "redis://deployer_redis@PUBLIC_IP:6379/#{env_num}",
namespace: "rails_app_#{Rails.env}" }
end
Sidekiq.configure_client do |config|
config.redis = { url: "redis://deployer_redis@PUBLIC_IP:6379/#{env_num}",
namespace: "rails_app_#{Rails.env}" }
end
When I do restart the Redis instance, the PUBLIC_IP will be different and the Rails app will not be able to connect to Redis.
I tried to use the PRIVATE_IP instead of the PUBLIC_IP (as PRIVATE_IP doesn't change while ), but it didn't work. There were no errors, but simply the jobs were not processed.
What's the recommended way to set the IP of EC2 instances in applications?
EDIT:
Also, when I ssh to the server, which IP should I use?