I'm testing out using memcached to cache django views. How can I tell if memcached is actually caching anything from the Linux command line?
相关问题
- Django __str__ returned non-string (type NoneType)
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Django restrict pages to certain users
- UnicodeEncodeError with attach_file on EmailMessag
相关文章
- Profiling Django with PyCharm
- Why doesn't Django enforce my unique_together
- MultiValueDictKeyError in Django admin
- Django/Heroku: FATAL: too many connections for rol
- Why is file_get_contents faster than memcache_get?
- Django is sooo slow? errno 32 broken pipe? dcramer
- Django: Replacement for the default ManyToMany Wid
- Upgrading transaction.commit_manually() to Django
Memcached can actually write to a logfile on its own, without having to resort to restarting it manually. The
/etc/init.d/memcached
init script can call memcached with the options specified in/etc/memcached.conf
. Among these options are verbosity and log file path.In short, you just need to add (or uncomment) these two lines to
/etc/memcached.conf
:...and restart the daemon with
service memcached restart
or/etc/init.d/memcached restart
And then you can monitor this log in the traditional way, like
tail -f /path/to/log
, for example.Start memcache not as a daemon but normal, so just run
memcached -vv
for very verbose. You will see when get's and sets come in to the memcache server.I wrote an
expect
scriptis-memcached-running
that tests if memcached is running on a host/port combination (run asis-memcached-running localhost 11211
):If you run your system from a
Makefile
rule, you could make your startup depend on a make target that asserts it is up and running (or helps you get that state). It is verbose when the check fails to make it easy for us to debug failed ci runs, installs memcached when it's missing, and is brief and to the point otherwise:You could use telnet and the stats command e.g.:
Can you use curl to fetch a page a few hundred times and time the results? You could also look at running a process on the server that simulates heavy CPU/disk load while doing this.
From the command line, try below command
echo stats | nc 127.0.0.1 11211*
If it doesn't return anything, memcache isn't running. Otherwise it should return a bunch of stats including uptime (and hit and miss counts)
The reference article is here, https://www.percona.com/blog/2008/11/26/a-quick-way-to-get-memcached-status/