Web Hosting Talk







View Full Version : Memcache experts knowledge needed


DoYouSpeakWak??
02-17-2010, 07:24 AM
Hey everybody

I got a few questions regarding memcache. After alot of searching i see very little topics that specificly talk about each line on config and what it does. And especially how to tweak it for large,medium,small sites and diffrent file types.

First off. Got any usefull links. Post them please.

This memcache
http://dk2.php.net/manual/en/book.memcache.php

< --- First question --- >

When setup. Do i need to clear the cache at some point to avoid it stacking up ?


< --- Second question --- >
When installing a deamon.

memcached -d -m 256 -l 10.0.0.40 -p 11211 -u memcached

I set the -m (stands for memory) to a certain number. Any suggestions about the size of this would be very welcome.



< --- Third one. (Going over these one by one) --- >

memcache.allow_failover "1"

(This is set to yes as standard,But why)

From the authors site
"Whether to transparently failover to other servers on errors. "

Q: What if i dont have more servers, just one server with one deamon running. Shouldnt this be uncommented in the ini file then ?

------------

memcache.max_failover_attempts "20"

Q: Same here, i still only have one server.


------------

memcache.chunk_size "8192"

Q: Makes sense.


------------

memcache.default_port "11211"

Q: Makes sense.


------------

memcache.hash_strategy "standard"

From the site

"Controls which strategy to use when mapping keys to servers. Set this value to consistent to enable consistent hashing which allows servers to be added or removed from the pool without causing keys to be remapped. Setting this value to standard results in the old strategy being used. "

Q: So if i set it to "consistent" it will enabel remapping. Is this good or bad for speed ?


------------

memcache.hash_function "crc32"

From the site
"Controls which hash function to apply when mapping keys to servers, crc32 uses the standard CRC32 hash while fnv uses FNV-1a. "

Q: So this is also related to the mapping of keys, With two diffrent options. "crc32" or "fnv" What is the diffrence if i enable remapping.


------------

session.save_handler "files"

From the site
"Use memcache as a session handler by setting this value to memcache. "

Q: Okay so i can let memcache handle sessions by chaning this to "memcache" Why should i do that, will it improve anything ?


------------

session.save_path

Q: Makes sense. But should this also be set if "session.save_handler" is set to files or only set if "session.save_handler" is set to memcache.



< --- Extended questions --- >

Things not covered by the installation guide at developers site.

More deamons. Instead of just one deamon its posible to run more at the time.

Q: Will it make memcache more effitient or faster ?

http://www.lullabot.com/articles/how_install_memcache_debian_etch


< --- Extra --- >

We will be using this for wikies,forums, blos etc. php, html,images mainly.

I hope some usefull information about the lovely software can come to light, to many all these little details are just details and hard to understand. So experts out there, Show us your knowledge.

aeris
02-17-2010, 08:53 AM
Ehh well, I'm no expert, but I have four memcached servers in use for a tens-of-megahits-per-day site, so..

When setup. Do i need to clear the cache at some point to avoid it stacking up ?

Not unless you start it with the -M option. It will remove old stuff when the cache is full.

When installing a deamon.

memcached -d -m 256 -l 10.0.0.40 -p 11211 -u memcached

I set the -m (stands for memory) to a certain number. Any suggestions about the size of this would be very welcome.

Depends on how you use it. You set it to 256, you can cache 256MB of stuff. Only simulations on real usage for a particular data set and application can tell how much cache it can make use of. I have about 12 GB of memcache space total, and while it takes a while for the cache to fill, it does eventually.


memcache.allow_failover "1"


memcache.max_failover_attempts "20"


memcache.hash_strategy "standard"

Doesn't matter with just one instance running. These things aren't used unless you use the multi-server way of initializing the memcache class (addServer instead of connect).

memcache.hash_function "crc32"

From the site
"Controls which hash function to apply when mapping keys to servers, crc32 uses the standard CRC32 hash while fnv uses FNV-1a. "

Q: So this is also related to the mapping of keys, With two diffrent options. "crc32" or "fnv" What is the diffrence if i enable remapping.

Don't think there is much of a difference. Both are simple non-cryptographic hashes, and any theoretical differences in distribution are irrelevant on a single server.


session.save_handler "files"

From the site
"Use memcache as a session handler by setting this value to memcache. "

Q: Okay so i can let memcache handle sessions by chaning this to "memcache" Why should i do that, will it improve anything ?

If you make use of the $_SESSION superglobal, you can use memcached instead of the standard file-backed storage.

------------

session.save_path

Q: Makes sense. But should this also be set if "session.save_handler" is set to files or only set if "session.save_handler" is set to memcache.

Set to the socket for the memcache server.

More deamons. Instead of just one deamon its posible to run more at the time.

Q: Will it make memcache more effitient or faster ?

You can, if you run them on different ports. It will create some connection overhead and will therefore likely be slower, but it's a way to get around process memory limits on 32-bit architectures.

DoYouSpeakWak??
03-17-2010, 08:16 PM
Thanks so much for your reply. (Better late than newer)