SamSaffron/MiniProfiler

rails + memcached store + unicorn fail to start in production

Closed this issue · 1 comments

Hello and thanks for awesome gem, it really helps those who believe performance is a feature.

I'm trying to include MiniProfiler into my rails 3.2 project, the setup is quite default:
rack-mini-profiler (0.1.23)
rails (3.2.8)
dalli (2.2.1)
unicorn (4.3.1)

When I try to use

# config/initializers/mini_profiler.rb
Rack::MiniProfiler.config.storage = Rack::MiniProfiler::MemcacheStore

I get NoMethod error saying that Hash has no method 'add'. This seems to deal with FileStore defaults, so I do

Rack::MiniProfiler.config.storage_instance = Rack::MiniProfiler::MemcacheStore.new

and then everything's ok in development, but in production I got a very confusing deadlock error. Futher investigation showed that this was because the default Dalli::Client is initialized with localhost:11211, which is not the same as 127.0.0.1:11211 (the Dalli default).

So adding

Rack::MiniProfiler.config.storage_instance = Rack::MiniProfiler::MemcacheStore.new(Dalli::Client.new)

fixed the problem. Unfortunately I don't have time to fork and submit PR, but I propose to just delete the offending parameter ['localhost:11211'] from Dalli::Client default initialization leaving dealing with defaults to Dalli itself. HTH

Memcachestore does indeed seem quite screwy...