ISO: Memcached config and tuning guides

123 views
Skip to first unread message

Ben Welsh

unread,
Apr 20, 2009, 1:54:48 PM4/20/09
to memcached
Hello,

I'm interested in trying to improve the performance of my memcached
system -- but not sure where to turn for guidance on best practices.
Are there any resources the list would recommend?

I'm managing a sitewide cache for a Postgres-Django-mod_python-Apache
site roughly along the lines of what's described here.

http://docs.djangoproject.com/en/1.0/topics/cache/

Recently I've been bumping up again the numfiles limit on my rig and
am now embarking on a mission to find solutions that might reduce the
problem. Any advice appreciated, as always.

Thank you.

Graham Dumpleton

unread,
Apr 20, 2009, 8:38:22 PM4/20/09
to memcached
This sort of problem can be related to what Apache MPM you are using.
So, are you using Apache prefork MPM or worker MPM? What are the MPM
settings being used in respect of the MPM you are using?

If your application is multithread safe, you may want to consider
using mod_wsgi in daemon mode instead as then you get more precise
control over number of processes/threads being used independent of
main Apach MPM settings, and can restrict them to a smaller number.

Graham

Ben Welsh

unread,
Apr 23, 2009, 2:38:10 PM4/23/09
to memcached
Graham --

Thanks for the response. I've been cruising around the web trying to
find the best solutions for the maximum open files errors i've been
drawing.

The support team at my host advised me that memcached was the source
of the problem -- but I've been getting different answers from
different people. And I'd love to hear more of what y'all have to say
here.

According to the postgresql server administration manuals, there is a
setting called `max_files_per_process` that could be tuned as well. My
main memcached concern is that I'm only getting a 20 percent hitrate,
according to django-memcached reports. And that's despite the fact
that I've configured the machine to do a Django-ish sitewide cache. A
sysadmin I consulted suggested that my memcached startup command might
have an error.

I ran:

$ memcached -d -p 11211 -u nobody -m 64 -c 1024 -P /var/run/memcached/
memcached.pid

And he suggests:

$ memcached -d -p 11211 -u nobody -m 64 -c 1024 -P /var/run/memcached/
memcached.pid -l 127.0.0.1:11211

To answer your question, my global apache conf has these basic
settings:

$ httpd -l
Compiled in modules:
core.c
prefork.c
http_core.c
mod_so.c

And from httpd.conf...

Timeout 20
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 5

<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>

Any feedback would be appreciated. I'm a developer who is trying to
take on these sysadmin responsibilities on a limited basis so my
coworkers have space to deploy new development techniques at a low
cost. It's obviously not my area of expertise -- and I'm scandalously
dependent on the kindness of strangers (and bloggers!) like
yourselves.

Thanks again for your great product and support community.

On Apr 20, 5:38 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages