memcached and fragment caching

i'm reading about memcached, which i never used before. it seems really interesting, but i found discording informations about it (and rails).

a) what is a reasonable memory usage for memcached? i read on some sites ~1gb while the default on my ubuntu server is only 64mb. i understand it's application dependent, but do you think that 128mb should be enough for most sites?

b) what about compression? it gives more cache hits, but is it performance costly?

c) i need a time based fragment expirations. i read about http://agilewebdevelopment.com/plugins/memcache_fragments_with_time_expiry but it return me a "plugin not found" error.

a) what is a reasonable memory usage for memcached? i read on some sites ~1gb while the default on my ubuntu server is only 64mb. i understand it's application dependent, but do you think that 128mb should be enough for most sites?

It completely depends on your application. I've run sites that had 4 servers with 1gb each, I've run sites that have 64mb... you need to figure out how much data you need to store. Start with 64 and let it run for a bit. Then connect to the memcache server and run 'stats' to get some data on how it's doing. Scroll down till you see the stat definition table... http://github.com/memcached/memcached/blob/master/doc/protocol.txt

b) what about compression? it gives more cache hits, but is it performance costly?

compression? Not sure what you mean. Memcached is very fast. Most people use it because their db isn't fast enough or to lighten the load...

c) i need a time based fragment expirations. i read about http://agilewebdevelopment.com/plugins/memcache_fragments_with_time_expiry but it return me a "plugin not found" error.

You shouldn't need a plugin to get going... add this to your environment.rb (or one of the specific ones in environments)

config.cache_store = :mem_cache_store, "localhost", {:namespace => 'foobar'}

Then in your views you can do things like:

<% cache(:some_unique_key, :expires_in => 15.minutes) do %>    complicated html goes here... <% end %>

And all the other caching stuff as well...

-philip

compression? Not sure what you mean. Memcached is very fast. Most
people use it because their db isn't fast enough or to lighten the
load...

it is an memcached options. but i'm not so convinced about it e.g.: memcache_options = {    :compression => true,    :namespace => "foobar",    :readonly => false, } i think the idea is to store more data on the cache. but compression/ decompression may slow down the process... if i don't find out something i will do a benchmark about it.

> c) > i need a time based fragment expirations. i read about >http://agilewebdevelopment.com/plugins/memcache_fragments_with_time_e… > but it return me a "plugin not found" error.

You shouldn't need a plugin to get going... add this to your
environment.rb (or one of the specific ones in environments)

config.cache_store = :mem_cache_store, "localhost", {:namespace =>
'foobar'}

Then in your views you can do things like:

<% cache(:some_unique_key, :expires_in => 15.minutes) do %> complicated html goes here... <% end %>

great.

thank you for your answer.

Well, you could use something like CloudCache and not worry about allocation - it’s elastic. There’s a drop-in implementation for the ActiveSupport::Cache interface:

http://github.com/quetzall/cloud_cache/

Of course that’s best used if you’re on EC2 (or EngineYard on EC2).

m

CloudCache is a paid service, btw. $0.05/MB/month. But they’re offering:

“Free 5 MB cache until Nov. 1, 2009!”

Hmm.

dwh

Marc Byrd wrote: