Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
conditional action caching multiple mongrel clusters
3 Posts
conditional action caching multiple mongrel clusters

We're using cache_fu plugin with memcache and using quite a bit of conditional action caching (unauthenticated user gets action caching, logged in user gets more dynamic page with fragment caching).

Everything works great and as expected in development environment.

However, in production environment (six app servers each running mongrel cluster) conditional action caching isn't working correctly - many actions act as if the :cacheable? method (in application.rb) is not even being called.

One odd thing is that some controller/actions are consistently using action caching properly, some don't work at all (the case where :cacheable? appears to have not been run), and some cases it works sometimes, other times not.

Not 100% sure on the set up, but request is either sent to one of several apache servers (app server) sitting in front of mongrel clusters for Rails, or to separate instance of apache on app servers that handles static files. According to the admin, he's using some sort of round robin in the apache sitting in front of the mongrel cluster, not mod_proxy.

I have gone down to the cache_fu plugin and added a few debug statement to see where it's failing, however, I suspect this really isn't a bug with cache_fu.

One other note - conditional action caching worked fine in our stage environment when it was running one app server and a mongrel cluster. When we switched our stage environment to use two app servers with a mongrel cluster each, we started seeing the problem. So it seems to be something with multiple app servers.

Any clues as what could be the culprit - something in our production configuration or anything we may need to do with routing (the 'welcome' route is one that fails consistently).

Thank you for any suggestions...

If I understand you correctly, you have 6 physically separate servers running apache, and each apache instance forwards requests to its own cluster of mongrel servers. And you have some sort of load balancer in front of the servers which forwards the incoming requests to the apache servers using a round-robin algorithm.

Could it be simply that a request comes in to server 1, which gets cached, then the next request for the same action goes to server 2, which loads it again because server 2 hasn't cached it yet?

Thanks for the reply.

We use memcache as a central datastore, so once any server sends the key, it should be good.

It actually looks like it's an issue with cache_fu. I've talked to someone who had a similar problem and modified fragment_cache.rb as they suggested, and I'm no longer having the problem. I'll be posting my results here and to the acts_as_cached google group once I'm certain of the solution. I've been running the modified plugin for five hours and so far it's working like a champ.

3 Posts
Login to add your message