How do I expire all rails cache instances at once?

I’ve scaled up my Rails 3 app to three separate instances, running behind a load balancer. I’m using Phusion Passenger as the app server. Each machine has it’s own memcached instance, and I use the Dalli gem for the client. I’m seeing an issue where when I clear the Rails cache manually through the rails console, it’s not clearing the caches on the other machines. It seems like the solution is to point each rails instances to the same memcached instance, or, to register each memcached server address with Dalli in the rails cache_store config. Has anyone encountered this issue before, and if so, what did you do?

Hi Daniel, thanks for your question! It sounds like you need to register each Memcached server with your configuration for this to work. From the Rails documentation:

When initializing the cache, you need to specify the addresses for all memcached servers in your cluster. If none is specified, it will assume memcached is running on the local host on the default port, but this is not an 

Would that work for you?

Thanks Philip. If I want to register the multiple servers, should I use the Private IPs of my different rails servers in the rails config file, and then also create firewall rules between the machines in the Cloud 66 Network / Firewall tab?

You must be logged in to answer this question