Last active
August 24, 2021 02:38
-
-
Save rayjanoka/91d7ef29067d1fc291a11e1aa3805498 to your computer and use it in GitHub Desktop.
Script and systemd service to apply I/O highest priority and best effort scheduling class to the etcd process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat <<'EOT' >/usr/local/bin/ionice-etcd.sh | |
#!/usr/bin/env bash | |
echo "Starting ionice etcd process watcher..." | |
while true; do | |
PID=$(pgrep etcd) | |
if [ "$PID" != "" ]; then | |
if [ "$(ionice -p $PID)" != "best-effort: prio 0" ]; then | |
echo "Setting I/O highest priority and best effort scheduling class for etcd PID: $PID" | |
ionice -c2 -n0 -p $PID | |
fi | |
fi | |
sleep 60 | |
done | |
EOT | |
chmod 0755 /usr/local/bin/ionice-etcd.sh | |
cat <<EOT >/etc/systemd/system/ionice-etcd.service | |
[Unit] | |
Description=ionice for etcd | |
After=kubelet.service | |
[Service] | |
DevicePolicy=closed | |
ExecStart=/usr/local/bin/ionice-etcd.sh | |
PrivateTmp=yes | |
ProtectSystem=strict | |
Restart=on-failure | |
TimeoutStartSec=10 | |
[Install] | |
WantedBy=multi-user.target | |
EOT | |
systemctl daemon-reload | |
systemctl enable ionice-etcd | |
systemctl start ionice-etcd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Written for Ubuntu
This I/O disk tuning is detailed in the
etcd
docs: https://etcd.io/docs/v3.2/tuning/#diskThis service will watch the
etcd
process in case it is restarted and re-apply the tuning.