Slow access when it matters
I have the lowest cost Linode plan, but it's turning out to be incapable of handling very simple tasks. I only need my server to occasionally transfer a small number of files over SSH. This is only done on rare occasion, yet first time access for the day is always slow, where a typical 7 second login and transfer task takes 23 seconds, subsequent runs of the EXACT same task are consistent and take 7 seconds. Most likely this is because my server has been suspended for inactivity and has to resume virtually. Is there a way to prevent this from happening? Do I need to just continually spam the server to keep it up, or will it adapt to that too once real work needs to be done. Will random tasks defeat the virtualization?
1 Reply
It sounds like the SSH connection is timing out. To address this, you can make some adjustments on both your Linode and on the machine that it's connecting to.
On your Linode, try updating these lines in your /etc/ssh/sshd_config
file with the new values:
ClientAliveInterval 120
ClientAliveCountMax 720
Once sshd
starts checking for client inactivity, it will check every 2 minutes (120 seconds) for up to 720 times - meaning this should not disconnect for 24 hours after the client side goes inactive. I imagine the client goes inactive, causing the broken pipe. Be sure to restart the sshd
service after making this change too:
sudo systemctl restart sshd
On your client (your local computer), we're going to make some changes as well. After taking a look at the man pages for ssh_config, it looks like the ServerAlive
directives will kill the connection if they don't receive a response either. You can try setting these back to their defaults (3 and 0 respectively), remove them, or use the same values we updated on your Linode:
ServerAliveInterval 120
ServerAliveCountMax 720
As a reminder, this is most likely located at ~/.ssh/config
on your computer.
In theory, this should keep your connection open for at least 24 hours regardless of responsiveness.