php - How is data replaced in memcached when it is full, and memcache performance? -
from memcached wiki:
when table full, subsequent inserts cause older data purged in least used (lru) order.
i have following questions:
which data purged? 1 older insertion, or 1 least used? mean if accessed data
d1
oldest insertion , cache full while replacing data replaced1
?i using php interacting memcached. can have control on how data replaced in memcached? not want of data replaced until expires if cache full. data should not replaced instead other data can removed insertion.
when data expired removed immediately?
what impact of number of keys stored on memcached performance?
what significance of
-k
option inmemcached.conf
? not able understand "lock down paged memory" means. also, description in readme not sufficient.
when memcached needs store new data in memory, , memory full, happen this:
- memcached searches a suitable* expired entry, , if 1 found, replaces data in entry. answers point 3) data not removed immediately, when new data should set, space reallocated
- if no expired entry found, 1 least used replaced
*keep in mind how memcached deals memory: allocates blocks of different sizes, size of data going set in cache plays role in deciding entry removed. entries 2k, 4k, 8k, 16k... etc 1m in size.
all information can found in documentation, read in carefully. @deceze says, memcached not guarantee data available in memory , have prepared cache miss storm. 1 interesting approach avoid miss storm set expiration time random offset, 10 + [0..10] minutes, means items stored 10, , other 20 minutes (the goal not of items expire @ same time).
and if want preserve in cache, have 2 things:
- a warm-up script, asks cache load data. used
- 2 expiration times item: 1 real expiration time, let's in 30 minutes; - cached along item - logical expiration time, let's in 10 minutes. when retrieve data cache, check logical expiration time , if expired - reload data , set in cache 30 minutes. in way you'll never hit real cache expiration time, , data periodically refreshed.
5) significance of -k option in "memcached.conf". not able understand "lock down paged memory" means. description in readme not sufficient.
no matter how memory allocate memcached, use amount needs, e.g. allocates memory used. -k
option however, entire memory reserved when memcached started, allocates whole amount of memory, no matter if needs or not
Comments
Post a Comment