Skip to content

Instantly share code, notes, and snippets.

@zentavr
Created December 14, 2015 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zentavr/4ad4d8a2f71a6d5cf0cd to your computer and use it in GitHub Desktop.
Save zentavr/4ad4d8a2f71a6d5cf0cd to your computer and use it in GitHub Desktop.
Files for ansible issue #13549
# Defaults for memcache setup defined here
---
memcached_port: 11211
memcached_listed_address: 0.0.0.0
memcached_max_conn: 2096
memcached_default_cache_size: 64
memcached_fs_file_max: 756024
memcached_logfile: /var/log/memcached.log
memcached_memory_chunks_multiplier: 1.25
memcached_memory_chunk_size: 48
---
- name: restart memcached
service: name=memcached state=restarted
# Look here: https://github.com/bennojoy/memcached
---
- name: Installing memcache package
apt: pkg=memcached state=latest
- name: Copy the client configuration file
template: src=memcached.conf.j2 dest=/etc/memcached.conf
notify: restart memcached
- name: Set the max open file descriptors
sysctl: name=fs.file-max value={{ memcached_fs_file_max }} state=present ignoreerrors=yes
- name: start the memcached service
service: name=memcached state=started enabled=yes
# memcached configuration file
# This configuration file is read by the start-memcached script provided as
# part of the Debian GNU/Linux distribution.
# This file is managed by Ansible deployment tool
# Run memcached as a daemon. This command is implied, and is not needed for the
# daemon to run. See the README.Debian that comes with this package for more
# information.
-d
# Log memcached's output to /var/log/memcached
logfile {{ memcached_logfile }}
# Be verbose
# -v
# Be even more verbose (print client commands as well)
# -vv
# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
{% if memcached_cache_size is defined and memcached_cache_size > 64 %}
-m {{ memcached_cache_size }}
{% elif ec2_instance_type == "m1.small" %}
# Total Memory Size is 1700
-m 1024
{% elif ec2_instance_type == "m1.medium" %}
# Total Memory Size is 3750
-m 3096
{% elif ec2_instance_type == "m3.medium" %}
# Total Memory Size is 3750
-m 3096
{% elif ec2_instance_type == "m1.large" %}
# Total Memory Size is 7450
-m 6800
{% elif ec2_instance_type == "m1.xlarge" %}
# Total Memory Size is 15000
-m 14336
{% elif ec2_instance_type == "m2.xlarge" %}
# Total Memory Size is 17079
-m 15000
{% elif ec2_instance_type == "m2.2xlarge" %}
-m 34304
{% elif ec2_instance_type == "m2.4xlarge" %}
-m 69120
{% elif ec2_instance_type == "m3.large" %}
# Total Memory Size is 7450
-m 6700
{% elif ec2_instance_type == "r3.large" %}
# Total Memory Size is 15000
-m 14336
{% elif ec2_instance_type == "r3.xlarge" %}
# Total Memory Size is 30500
-m 27000
{% elif ec2_instance_type == "r3.2xlarge" %}
# Total Memory Size is 61000
-m 53070
{% elif ec2_instance_type == "r3.4xlarge" %}
# Total Memory Size is 122000
-m 115000
{% elif ec2_instance_type == "r3.8xlarge" %}
# Total Memory Size is 244000
-m 238000
{% else %}
# Setting up the default size
-m {{ memcached_default_cache_size }}
{% endif %}
# Default connection port is 11211
-p {{ memcached_port }}
# Run the daemon as root. The start-memcached will default to running as root if no
# -u command is present in this config file
-u memcache
# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.
-l {{ memcached_listed_address }}
# Limit the number of simultaneous incoming connections. The daemon default is 1024
-c {{ memcached_max_conn }}
# Lock down all paged memory. Consult with the README and homepage before you do this
# -k
# Return error when memory is exhausted (rather than removing items)
# -M
# Maximize core file limit
# -r
# A multiplier for computing the sizes of memory chunks that items are stored in. (Default: 1.25)
-f {{ memcached_memory_chunks_multiplier }}
# Memory Chunk Size (Default: 48 bytes)
-n {{ memcached_memory_chunk_size }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment