Skip to content

Commit 3f1bb4a

Browse files
committed
Redis Threading
Adds Redis I/O threading if the system has 4 or more available threads.
1 parent 732464f commit 3f1bb4a

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

scripts/install/redis/redis-install.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,46 @@ chmod 775 /var/log/redis
4141
#chown -R redis:redis /var/lib/redis
4242
#chown -R redis:redis /var/log/redis
4343

44+
# Copy Redis Config File
4445
cp -rf /usr/local/bin/enginescript/etc/redis/redis.conf /etc/redis/redis.conf
46+
47+
# Redis Tuning
4548
sed -i "s|SEDREDISMAXMEM|${SERVER_MEMORY_TOTAL_06}|g" /etc/redis/redis.conf
49+
50+
if [[ "${CPU_COUNT}" -ge '16' ]]; then
51+
sed -i "s|^# io-threads 4|io-threads 8|" /etc/redis/redis.conf
52+
sed -i "s|^# io-threads-do-reads no|io-threads-do-reads yes|" /etc/redis/redis.conf
53+
elif [[ "${CPU_COUNT}" -ge '12' && "${CPU_COUNT}" -le '15' ]]; then
54+
sed -i "s|^# io-threads 4|io-threads 6|" /etc/redis/redis.conf
55+
sed -i "s|^# io-threads-do-reads no|io-threads-do-reads yes|" /etc/redis/redis.conf
56+
elif [[ "${CPU_COUNT}" -ge '7' && "${CPU_COUNT}" -le '11' ]]; then
57+
sed -i "s|^# io-threads 4|io-threads 4|" /etc/redis/redis.conf
58+
sed -i "s|^# io-threads-do-reads no|io-threads-do-reads yes|" /etc/redis/redis.conf
59+
elif [[ "${CPU_COUNT}" -ge '4' && "${CPU_COUNT}" -le '6' ]]; then
60+
sed -i "s|^# io-threads 4|io-threads 2|" /etc/redis/redis.conf
61+
sed -i "s|^# io-threads-do-reads no|io-threads-do-reads yes|" /etc/redis/redis.conf
62+
fi
63+
64+
# Redis Service
4665
#sed -i "s|Type=notify|Type=forking|g" /lib/systemd/system/redis-server.service
4766
sed -i "s|--daemonize no|--daemonize yes|g" /lib/systemd/system/redis-server.service
4867
sed -i "s|ReadWritePaths=-/var/run|ReadWritePaths=-/run|g" /lib/systemd/system/redis-server.service
68+
69+
# Permissions
4970
chown -R redis:redis /etc/redis/redis.conf
5071
chmod 775 /etc/redis/redis.conf
72+
73+
# Finalize Redis Install
5174
systemctl daemon-reload
5275
service redis-server restart
5376
sudo systemctl enable redis-server
5477

5578
# Redis Service Check
5679
STATUS="$(systemctl is-active redis)"
5780
if [ "${STATUS}" = "active" ]; then
58-
echo "PASSED: Redis is running."
59-
echo "REDIS=1" >> /home/EngineScript/install-log.txt
81+
echo "PASSED: Redis is running."
82+
echo "REDIS=1" >> /home/EngineScript/install-log.txt
6083
else
61-
echo "FAILED: Redis not running. Please diagnose this issue before proceeding."
62-
exit 1
84+
echo "FAILED: Redis not running. Please diagnose this issue before proceeding."
85+
exit 1
6386
fi

0 commit comments

Comments
 (0)