puppet: Automatically scale default memcached memory allocation.

Previously, we used a fixed memcached memory allocation of 512MB,
regardless of the size of the server.  While that is a good allocation
for a server with 4GB of RAM, for servers with less, we should
decrease the allocation, and for a large server with much more RAM, we
should increase it.  We still support the user overriding the
configuration setting, but this produces more sensible defaults.
This commit is contained in:
Tim Abbott 2016-08-11 20:24:25 -07:00
parent 2e0e8193d4
commit 2581ac166c
1 changed files with 2 additions and 1 deletions

View File

@ -2,7 +2,8 @@ class zulip::memcached {
$memcached_packages = ["memcached"]
package { $memcached_packages: ensure => "installed" }
$memcached_memory = zulipconf("memcached", "memory", "512")
$total_memory_mb = regsubst(file('/proc/meminfo'), '^.*MemTotal:\s*(\d+) kB.*$', '\1', 'M') / 1024
$memcached_memory = zulipconf("memcached", "memory", $total_memory_mb / 8)
file { "/etc/memcached.conf":
require => Package[memcached],
ensure => file,