I have a small dev vm running Debain11. I use remote-ssh with VSCode to connect. Very often my connection gets dropped/unresponsive. When connecting using SSH and the -v flag I can see that the actual connection does occur, but the server doesn't respond with the protocol response.
After about 6 minutes it does connect, but with extreme lag < 10000 ms. Restarting the server solves it for a bit. No demanding software is running and running uptime
shows load average: 0.00, 0.00, 0.00.
port 22 is opened and no other security groups are set. The VM does not have an internal firewall set. All IP's are allowed. The key is correct and connects fine after VM stop and start.
Update: Software running
Postgresql 13 with one small dev database that is only being hit manually by me.
pgAdmin4 - only on localhost and only used by two users.
Metrics like CPU and RAM and Disk IO are all normal.
What else can I check?
No. CPU and Disk IO are all well below threshold and usually less than 3% usage. Nothing is running on it beyond 'pgadmin4' and postgres. Since this is a dev machine and these packages are configured to only be reachable from local host they are not the issue. The database has one table with maybe ten rows.
To augment the metrics in the EC2 section of the AWS Console (which aren't all that great) you could setup CloudWatch agent to collect more detail https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html
For more detail on the what's being used on the OS side something like sar would be helpful https://wiki.debian.org/sysstat