Newbie question: memcached slow the first time a value is read?
Alex Stapleton
alexs at advfn.com
Wed Dec 7 12:35:22 UTC 2005
On 7 Dec 2005, at 11:49, Ask Bjørn Hansen wrote:
>
> On Dec 7, 2005, at 3:27 AM, Tim Strehle wrote:
>
>> - So I installed memcached (memcached-1.1.12 with libevent-1.1a on
>> SuSE Linux 9.3, kernel version 2.6.11.4-21.9-bigsmp, single Xeon
>> 2.4 GHz with 3 GB RAM) and the PHP PECL memcache extension
>> (memcache-1.5 on PHP 4.4.0), started memcached with 1.5 GB RAM
>> ("memcached -d -u digicol -m 1536 -M -l 127.0.0.1 -p 11211") and
>> ran a PHP script to fill it with the metatdata for those 2.5
>> million documents.
>>
>> I understand from "top" that my PHP script wrote 1145 MB of data
>> into memcached:
>>
>> =====================================================================
>> ===
>> Tasks: 73 total, 1 running, 72 sleeping, 0 stopped, 0 zombie
>> Cpu(s): 0.0% us, 0.2% sy, 0.0% ni, 99.3% id, 0.5% wa, 0.0%
>> hi, 0.0% si
>> Mem: 3111540k total, 1868280k used, 1243260k free, 833312k
>> buffers
>> Swap: 2104472k total, 479964k used, 1624508k free, 86204k
>> cached
>>
>> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
>> 13278 digicol 16 0 1145m 739m 468 S 0.0 24.4 2:38.86
>> memcached
>
> If I'm reading this right (darn proportional fonts) then yes, you
> are swapping memcached!
>
> (and/or you are swapping something else which on most webservers is
> a terribly terribly thing to do).
>
You may also want to set swappiness to 0 so that Linux is less likely
to swap it out and will favour eating up the page cache instead.
echo 0 > /proc/sys/vm/swappiness
Should do it. Depends on what else your using the machine for though.
More information about the memcached
mailing list