Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a preferred way to set "nice" for sshd?

I need priority given to sshd such that I can login and easily fix stuff when something has gone wrong (eg DoS, badly behaved processes, etc)

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

You can give your preferred user account or user group a nice value in /etc/security/limits.conf, at least if we are talking about Linux. Then when you login via sshd, you will have nice value of X, whatever you set it.

In my experience the CPU scheduler in kernel is nowadays so good it's hard to make server unmanageably sluggish just by burning CPU cycles, shell will usually respond in reasonable time.

If your server struggles to respond to you via ssh, then it most likely is swapping itself to death. Everything starts to take ages if server consumes all its time for swapping pages in and out of memory to disk.

That's why better approach is to set up cgroups, so your user always have some spare CPU cycles / memory / other resources left. As said by viqrto, it may or may not help.

share|improve this answer
    
I'll look into cgroups. Re limits.conf, I guess that would only come into effect once sshd has accepted the connection and launched a shell process under my username. I wonder if I should also edit /etc/init/ssh.conf (upstart) and add a nice -15 to sshd to prioritise the actual sshd daemon? –  s29 Jan 31 '12 at 14:41
add comment

You need to limit the number of processes(threads). Most of the demon has its own settings. Apache for example. Then the scheduler will always allocate an appropriate amount of CPU time for SSH servers.

cpulimit or cgroup can limit the cpu usage of a process. This may help, but it may not

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.