2 min

Nginx and Memcached - September 2014

http://memcached.org

On Oct 2, 2014, I installed Memcached.
apt-get install memcached

The above installed version 1.4.13.

As of Oct 20, 2014, the latest stable memcached release is v1.4.21.

/etc/memcached.conf

/etc/init.d/memcached

/usr/share/memcached/scripts/start-memcached

listens on port 11211

http://wiki.nginx.org/HttpMemcachedModule

http://nginx.org/en/docs/http/ngx_http_memcached_module.html

https://www.igvita.com/2008/02/11/nginx-and-memcached-a-400-boost/

http://blog.octo.com/en/http-caching-with-nginx-and-memcached/

http://stackoverflow.com/questions/5150995/how-to-configure-nginx-with-memcached-to-serve-html

https://wildlyinaccurate.com/blazing-fast-wordpress-with-nginx-and-memcached

http://www.nginxtips.com/improving-wordpress-performance-nginx-php-fpm-mysql-memcached-w3-total-cache/

enhanced module:

https://github.com/bpaquet/ngx_http_enhanced_memcached_module

Perl Clients

Pure Perl:
Cache::Memcached
http://search.cpan.org/~dormando/Cache-Memcached-1.30/lib/Cache/Memcached.pm


Perl client written in C:
Cache::Memcached::Fast
http://search.cpan.org/~kroki/Cache-Memcached-Fast-0.22/lib/Cache/Memcached/Fast.pm

Installed on Oct 20, 2014
perl -MCPAN -e 'install Cache::Memcached::Fast'


http://search.cpan.org/~mdorman/Memcached-Client-2.01/lib/Memcached/Client.pm

install failed


http://search.cpan.org/~elizabeth/Cache-Memcached-Managed-0.24/lib/Cache/Memcached/Managed.pm

Installed on Oct 20, 2014
perl -MCPAN -e 'install Cache::Memcached::Managed'

that install managed to install Cache::Memcached.


http://search.cpan.org/dist/Cache-Memcached-libmemcached/lib/Cache/Memcached/libmemcached.pm

Installed on Oct 20, 2014

perl -MCPAN -e 'install Cache::Memcached::libmemcached '

http://libmemcached.org/libMemcached.html

http://docs.libmemcached.org/

my Perl code in Grebe uses libmemcached

docs

https://code.google.com/p/memcached/wiki/NewProgramming

https://github.com/memcached/memcached/blob/master/doc/protocol.txt

https://code.google.com/p/memcached/wiki/NewCommands

http://lzone.de/articles/memcached.htm

http://skipperkongen.dk/2013/01/21/summary-of-memcached-commands-as-used-through-telnet/

[X] http://www.journaldev.com/16/memcached-telnet-commands-with-example

[X] http://blog.elijaa.org/index.php?post/2010/05/21/Memcached-telnet-command-summary

For my new uses, I think Redis will be easier. Redis allows a hash type, so that I can purge the entire cache for a top level domain. And since I host multiple websites on the same server and store those sites' content in the same Redis server, it's easier to remove the cache for one site within Redis.

Within Memcached, I could store key-value data like this:
birdbrainsbrewing.com-1 "html content for page id 1"
birdbrainsbrewing.com-5 "html content for page id 5"
maketoledo.com-1 "html content for page id 1"

But I cannot determine how to remove all the keys for one domain. For Redis, I delete the hash birdbrainsbrewing.com and all those cache pages are removed.

At the moment, it seems that I can only delete one key at a time for Memcached. A flush_all command will remove the entire cache. That's fine if I only hosted one site within Memcached.

For Memcached, I would need to run a version or instance of server for each site that's hosted on the same Linux server, and then specify the port number within my Grebe YAML config file. If this is possible to do.

Then key-value would be simply:
1 'html for page id 1'
2 'html for page id 2'

https://code.google.com/p/memcached/wiki/NewConfiguringServer#Multiple_Instances

https://gist.github.com/gimler/612961

http://stackoverflow.com/questions/5928387/how-can-we-create-two-instances-of-memcached-server-in-same-server-in-different

http://www.nginxtips.com/configure-multiple-memcached-instances/

http://serverfault.com/questions/361894/dividing-memcached-between-sites

http://serverfault.com/questions/215676/multiple-memcached-server-etc-init-d-startup-script-that-works

http://www.vionblog.com/multiple-memcached-instances-on-one-server/

simple instance startup:
memcached -m 24 -p 11212 -d

Multiple instances

http://stackoverflow.com/questions/5928387/how-can-we-create-two-instances-of-memcached-server-in-same-server-in-different

I followed instructions in /etc/init.d/memcached which simply states: within /etc I copied memcached.conf to maketoledo.conf and birdbrainsbrewing.conf.

then I modified each config file and changed the port number.

then I restarted memcached
service memcached restart

showed processes
ps aux | grep memcached

the default memcached.conf will continue to listen on port 11211, and I'll use this for Grebe development.

the maketoledo.conf instance listens on port 11212.

the birdbrainsbrewing.conf instance listens on port 11213.

the basic commands that I will use:
set
get
flush_all

#nginx - #memcached - #cache - #scalability

From JR's : articles
437 words - 4895 chars - 2 min read
created on
updated on - #
source - versions - backlinks



A     A     A     A     A

© 2013-2017 JotHut - Online notebook

current date: May 27, 2024 - 8:04 p.m. EDT