From ad31cc97932ded7d3b79ce6d4e5d98684a2318aa Mon Sep 17 00:00:00 2001 From: Ark74 Date: Thu, 13 May 2021 20:21:18 -0500 Subject: [PATCH] Include high performance system tuning as default --- mode/chp-mode.sh | 35 +++------------- mode/jms-stu.sh | 86 ++++++++++++++++++++++++++++++++++++++++ quick_jibri_installer.sh | 7 ++++ 3 files changed, 99 insertions(+), 29 deletions(-) create mode 100644 mode/jms-stu.sh diff --git a/mode/chp-mode.sh b/mode/chp-mode.sh index 8e0f7e9..7c4b760 100644 --- a/mode/chp-mode.sh +++ b/mode/chp-mode.sh @@ -160,35 +160,12 @@ elif [ "$CHAT_DISABLED" = "yes" ] || [ -z "$CHAT_DISABLED" ]; then fi done -#SYSTEM -##Disable swap -swapoff -a -sed -ir '/\sswap\s/s/^#?/#/' $FSTAB - -##Kernel -#https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/tuning_and_optimizing_red_hat_enterprise_linux_for_oracle_9i_and_10g_databases/sect-oracle_9i_and_10g_tuning_guide-adjusting_network_settings-changing_network_kernel_settings -sysctl -w net.core.rmem_default=262144 -sysctl -w net.core.wmem_default=262144 -sysctl -w net.core.rmem_max=262144 -sysctl -w net.core.wmem_max=262144 -set_once "net.core.rmem_default=262144" "/etc/sysctl.conf" -set_once "net.core.wmem_default=262144" "/etc/sysctl.conf" -set_once "net.core.rmem_max=262144" "/etc/sysctl.conf" -set_once "net.core.wmem_max=262144" "/etc/sysctl.conf" - -#https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux_for_real_time/7/html/tuning_guide/reduce_tcp_performance_spikes -sysctl -w net.ipv4.tcp_timestamps=0 -set_once "net.ipv4.tcp_timestamps=0" "/etc/sysctl.conf" - -#https://bugzilla.redhat.com/show_bug.cgi?id=1283676 -sysctl -w net.core.netdev_max_backlog=100000 -set_once "net.core.netdev_max_backlog=100000" "/etc/sysctl.conf" - -##nginx -sed -i "s|worker_connections.*|worker_connections 2000;|" /etc/nginx/nginx.conf - -#Missing docs -#sysctl -w net.ipv4.tcp_low_latency=1 +## JMS system tune up +if [ "$MODE" = "debug" ]; then + bash $PWD/jms-stu.sh -m debug +else + bash $PWD/jms-stu.sh +fi #JVB2 ##Loose up logging diff --git a/mode/jms-stu.sh b/mode/jms-stu.sh new file mode 100644 index 0000000..9041b15 --- /dev/null +++ b/mode/jms-stu.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# System-tune-up to remove system restrictions on a huge load of connections. +# SwITNet Ltd © - 2021, https://switnet.net/ +# GPLv3 or later. + +#Check if user is root +if ! [ $(id -u) = 0 ]; then + echo "You need to be root or have privileges!" + exit 0 +fi + +while getopts m: option +do + case "${option}" + in + m) MODE=${OPTARG};; + \?) echo "Usage: sudo ./jms-stu.sh [-m debug]" && exit;; + esac +done + +echo ' +#-------------------------------------------------- +# Starting system tune up configuration +# for high performance +#-------------------------------------------------- +' + +#DEBUG +if [ "$MODE" = "debug" ]; then +set -x +fi + +set_once() { +if [ -z "$(awk '!/^ *#/ && NF {print}' "$2"|grep $(echo $1|awk -F '=' '{print$1}'))" ]; then + echo "Setting "$1" on "$2"..." + echo "$1" | tee -a "$2" +else + echo " \"$(echo $1|awk -F '=' '{print$1}')\" seems present, skipping setting this variable" +fi +} + +##Disable swap +swapoff -a +sed -r '/\sswap\s/s/^#?/#/' -i $FSTAB + +##Alternative swap tuning (need more documentation). +#vm.swappiness=10 +#vm.vfs_cache_pressure=50 + +##Kernel +#https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/tuning_and_optimizing_red_hat_enterprise_linux_for_oracle_9i_and_10g_databases/sect-oracle_9i_and_10g_tuning_guide-adjusting_network_settings-changing_network_kernel_settings +sysctl -w net.core.rmem_default=262144 +sysctl -w net.core.wmem_default=262144 +sysctl -w net.core.rmem_max=262144 +sysctl -w net.core.wmem_max=262144 +set_once "net.core.rmem_default=262144" "/etc/sysctl.conf" +set_once "net.core.wmem_default=262144" "/etc/sysctl.conf" +set_once "net.core.rmem_max=262144" "/etc/sysctl.conf" +set_once "net.core.wmem_max=262144" "/etc/sysctl.conf" + +#system +#https://jitsi.github.io/handbook/docs/devops-guide/devops-guide-quickstart +sysctl -w DefaultLimitNOFILE=65000 +sysctl -w DefaultLimitNPROC=65000 +sysctl -w DefaultTasksMax=65000 +set_once "DefaultLimitNOFILE=65000" "/etc/sysctl.conf" +set_once "DefaultLimitNPROC=65000" "/etc/sysctl.conf" +set_once "DefaultTasksMax=65000" "/etc/sysctl.conf" + +#https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux_for_real_time/7/html/tuning_guide/reduce_tcp_performance_spikes +sysctl -w net.ipv4.tcp_timestamps=0 +set_once "net.ipv4.tcp_timestamps=0" "/etc/sysctl.conf" + +#https://bugzilla.redhat.com/show_bug.cgi?id=1283676 +sysctl -w net.core.netdev_max_backlog=100000 +set_once "net.core.netdev_max_backlog=100000" "/etc/sysctl.conf" + +##nginx +sed -i "s|worker_connections.*|worker_connections 2000;|" /etc/nginx/nginx.conf +nginx -t + +#Missing docs +#sysctl -w net.ipv4.tcp_low_latency=1 + +echo "System tune up... + Done!" diff --git a/quick_jibri_installer.sh b/quick_jibri_installer.sh index 4531737..bd9d43e 100644 --- a/quick_jibri_installer.sh +++ b/quick_jibri_installer.sh @@ -415,6 +415,13 @@ Remove Chrome warning... mkdir -p /etc/opt/chrome/policies/managed echo '{ "CommandLineFlagSecurityWarningsEnabled": false }' > $GCMP_JSON +## JMS system tune up +if [ "$MODE" = "debug" ]; then + bash $PWD/mode/jms-stu.sh -m debug +else + bash $PWD/mode/jms-stu.sh +fi + echo ' ######################################################################## Please Setup Your Installation