Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compression and eviction policy to in-memory cache. #783

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 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).
## 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 && \
## 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
Expand Down
1 change: 1 addition & 0 deletions deploy/development/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 1 addition & 0 deletions deploy/staging/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Loading