Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 2.15 KB

FAQ.rdoc

File metadata and controls

42 lines (29 loc) · 2.15 KB

Memcache-client FAQ

Does memcache-client work with Ruby 1.9?

Yes, Ruby 1.9 is supported. The test suite should pass completely on 1.8.6 and 1.9.1.

I’m seeing “execution expired” or “time’s up!” errors, what’s that all about?

memcache-client 1.6.x+ now has socket operations timed out by default. This is to prevent the Ruby process from hanging if memcached or starling get into a bad state, which has been seen in production by both 37signals and FiveRuns. The default timeout is 0.5 seconds, which should be more than enough time under normal circumstances. It’s possible to hit a storm of concurrent events which cause this timer to expire: a large Ruby VM can cause the GC to take a while, while also storing a large (500k-1MB value), for example.

You can increase the timeout or disable them completely with the following configuration:

Rails:
config.cache_store = :mem_cache_store, 'server1', 'server2', { :timeout => nil } # no timeout

native:
MemCache.new ['server1', 'server2'], { :timeout => 1.0 } # 1 second timeout

The new memcache-client is slower than 1.5.0!?

Yes, in the simplest case, 1.6.x+ is slower than 1.5.0. If you just have a single memcached server, the latest memcache-client will be significantly slower. This is because 1.5.0 does not timeout network operations. For reliability purposes, memcache-client 1.6.x+ enables timeouts by default.

Unfortunately Ruby’s network timeout options are not very performant. If you want timeouts, the best you can do currently is install the SystemTimer gem, which will approximately halve the overhead incurred by timeouts. If you need ultimate speed, you can disable timeouts or use Fauna’s memcached library which moves most of the client into native C. (Hint: if you are looking for a fun tuning project and are good with C, the SystemTimer gem has a lot of room for improvement in performance.)

If you are using multiple memcached servers, 1.6.x+ will be much faster than 1.5.0 as 1.5.0 had an extremely slow hashing function to map a key to a server. Overall, production environments with multiple servers should see performance and reliability improvements in memcache-client 1.6.x+.