I recently updated Discourse from version 3.4.0.beta1 to 3.4.0.beta3. After the update, we are noticing that the forum’s memory usage is gradually increasing, causing the application to go down. When checking the server, we can see that the redis-server is consuming 95% of the memory.
We are running redis-cli flushall daily to temporarily fix the issue. The Discourse instance is hosted in Docker.
I tried to downgrade to the previous version, but it was throwing a few errors while rebuilding.
As a temporary fix, I created a small bash script to clean up Redis memory and set it to run every day at 6 AM using a cron job.
Note: I’m saving the log in /home/ubuntu/logs. You can ignore it if you don’t need it.
#!/bin/bash
# Set log directory and filename
LOG_DIR="/home/ubuntu/logs"
LOG_FILE="$LOG_DIR/redis.cleanup.$(date +\%Y-\%m-\%d).log"
# Ensure the log directory exists
mkdir -p "$LOG_DIR"
# Log information about the current environment (host side)
echo "Running script at $(date)" >> "$LOG_FILE"
# Run the discourse launcher in the app and save output to the log file (host side)
echo "redis cleanup command" >> "$LOG_FILE"
docker exec app redis-cli flushall >> "$LOG_FILE" 2>&1
# Indicate that the script is done (host side) and exit
echo "Script completed successfully at $(date)" >> "$LOG_FILE"
exit 0
Update: Seems like it’s been auto-fixed. Now that I’m remembering, we had a similar issue last time when we updated the version, and the memory kept spiking, but it fixed itself after a while. It seems like it’s a bug.