Strangely on few on my linux servers, intermittently, when i try to login through ssh and run commands, they take about 15-30 secs to execute every command. Every commands is executed very slow. But as soon as the command executes, then it performs normal funtion, (i mean does not slows down).
I have checked, CPU, RAM, IO, Network, everything is in normal condition. so what could be the issue?
Check swap memory(
free -h
) utilization.If some processes consume high amounts of swap memory this may cause slowness of the system which in turn takes more time to execute commands.
Most modern OSs tend to cache as much as they can in RAM. The first time you run a command, it might take long to retrieve all information from disk. On subsequent attempts the data is already cached and things run much faster. A common scenario in which you expèrience this is on DB servers: a heavy SQL query can take long to execute, if you then run the query again the execution is immediate, as the data is already there.