From 78a74acc2c3affa395bb6e411b90049fa0e8ef02 Mon Sep 17 00:00:00 2001 From: EarthlingDavey <15802017+EarthlingDavey@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:38:38 +0000 Subject: [PATCH 1/3] Add compression and eviction policy to in-memory cache. --- Dockerfile | 24 ++++++++++++++++++------ deploy/development/config.yml | 1 + deploy/staging/config.yml | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index ab4ee08b9..c35ad9905 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,12 +60,24 @@ RUN rm zz-docker.conf && \ ## Set our pool configuration COPY deploy/config/php-pool.conf pool.conf -# Apend our relay config to the existing config file. -RUN { \ - echo 'relay.maxmemory = 16M'; \ - echo 'relay.loglevel = error'; \ - echo 'relay.logfile = /dev/stderr'; \ - } >> /usr/local/etc/php/conf.d/docker-php-ext-relay.ini +# Configure Relay - See https://relay.so/docs/1.x/configuration +RUN RELAY_CONFIG_FILE=/usr/local/etc/php/conf.d/docker-php-ext-relay.ini && \ + # Set log level to notice + sed -i 's/^;\? \?relay.loglevel =.*/relay.loglevel = notice/' $RELAY_CONFIG_FILE && \ + # Set log file to stderr + sed -i 's/^;\? \?relay.logfile =.*/relay.logfile = \/dev\/stderr/' $RELAY_CONFIG_FILE && \ + # Settings related to the in-memory cache (not Redis). + ## Set maxmemory to 16M. + sed -i 's/^;\? \?relay.maxmemory =.*/relay.maxmemory = 16M/' $RELAY_CONFIG_FILE && \ + ## Eviction policy: lru. Evicts the least recently used keys out of all keys when relay.maxmemory_pct is reached + sed -i 's/^;\? \?relay.eviction_policy =.*/relay.eviction_policy = lru/' $RELAY_CONFIG_FILE && \ + ## Start evicting keys when 90% of the memory is used. + sed -i 's/^;\? \?relay.maxmemory_pct =.*/relay.maxmemory_pct = 90/' $RELAY_CONFIG_FILE && \ + ## Set the session compression to lz4 + sed -i 's/^;\? \?relay.session.compression =.*/relay.session.compression = lz4/' $RELAY_CONFIG_FILE && \ + ## Set the session compression level to 1 + sed -i 's/^;\? \?relay.session.compression_level =.*/relay.session.compression_level = 1/' $RELAY_CONFIG_FILE + # Don't log every request. RUN perl -pi -e 's#^(?=access\.log\b)#;#' /usr/local/etc/php-fpm.d/docker.conf diff --git a/deploy/development/config.yml b/deploy/development/config.yml index e3ff1c7dd..36b503f88 100644 --- a/deploy/development/config.yml +++ b/deploy/development/config.yml @@ -12,3 +12,4 @@ data: # The following IDs are not private, they form part of the publicly visible oauth login url. OAUTH_CLIENT_ID: "51266573-d4eb-41db-8ebe-a9548aa4f01e" OAUTH_TENANT_ID: "0bb413d7-160d-4839-868a-f3d46537f6af" + WP_REDIS_USE_RELAY: 'true' diff --git a/deploy/staging/config.yml b/deploy/staging/config.yml index 2cacb35ea..b9ac0c874 100644 --- a/deploy/staging/config.yml +++ b/deploy/staging/config.yml @@ -12,3 +12,4 @@ data: # The following IDs are not private, they form part of the publicly visible oauth login url. OAUTH_CLIENT_ID: "ffb808d2-312b-4ffe-a6e5-d6eacfd9f06f" OAUTH_TENANT_ID: "c6874728-71e6-41fe-a9e1-2e8c36776ad8" + WP_REDIS_USE_RELAY: 'true' From f058d20800bdcc0d227339dc3f8982ec9b948370 Mon Sep 17 00:00:00 2001 From: EarthlingDavey <15802017+EarthlingDavey@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:39:59 +0000 Subject: [PATCH 2/3] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c35ad9905..2c0f318a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,7 +67,7 @@ RUN RELAY_CONFIG_FILE=/usr/local/etc/php/conf.d/docker-php-ext-relay.ini && \ # Set log file to stderr sed -i 's/^;\? \?relay.logfile =.*/relay.logfile = \/dev\/stderr/' $RELAY_CONFIG_FILE && \ # Settings related to the in-memory cache (not Redis). - ## Set maxmemory to 16M. + ## Set maxmemory to 16M - this is the max. w/o a license. sed -i 's/^;\? \?relay.maxmemory =.*/relay.maxmemory = 16M/' $RELAY_CONFIG_FILE && \ ## Eviction policy: lru. Evicts the least recently used keys out of all keys when relay.maxmemory_pct is reached sed -i 's/^;\? \?relay.eviction_policy =.*/relay.eviction_policy = lru/' $RELAY_CONFIG_FILE && \ From 15085d7b225e0e47f88221decf5d3f19d68a69eb Mon Sep 17 00:00:00 2001 From: EarthlingDavey <15802017+EarthlingDavey@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:12:17 +0000 Subject: [PATCH 3/3] Change log level to error to reduce noise --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2c0f318a5..a7239552a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,8 +62,8 @@ COPY deploy/config/php-pool.conf pool.conf # Configure Relay - See https://relay.so/docs/1.x/configuration RUN RELAY_CONFIG_FILE=/usr/local/etc/php/conf.d/docker-php-ext-relay.ini && \ - # Set log level to notice - sed -i 's/^;\? \?relay.loglevel =.*/relay.loglevel = notice/' $RELAY_CONFIG_FILE && \ + # Set log level to error + sed -i 's/^;\? \?relay.loglevel =.*/relay.loglevel = error/' $RELAY_CONFIG_FILE && \ # Set log file to stderr sed -i 's/^;\? \?relay.logfile =.*/relay.logfile = \/dev\/stderr/' $RELAY_CONFIG_FILE && \ # Settings related to the in-memory cache (not Redis).