1

How do I make a part of main memory dedicated for the system only to use for SSH process?

Every time my server is running some machine learning applications the main memory gets totally full and wont allow anyone even to do an ssh. We have a server with 64GB Main memory.

I want 63 GB can be used for all other processes by all other users, but want to make remaining 1GB exclusively just to start SSH process. Any threads on this would be really of great help.

-1

Some approaches I can think of:

  1. Give the SSH process higher priority.

    renice -n -10 -p `pidof sshd`
    

    With higher priority, ssh server can be frequently scheduled in CPU; as a result, it will less likely be swapped off to disk.

  2. Use Systemd's Resource control module to control resource usage of your machine learning program. You can use apply MemoryMax to a user slice so that all processes started in that user session cannot use more memory than the value specified. The command is:

    systemctl set-property MemoryMax=5G user-XXXX.slice
    

    Or maybe use the same trick on the ssh server with MemoryLow.

  • I also heard about memlockd, but never try it. – Yun-Chih Chen Nov 2 '16 at 15:41
  • renice has nothing to do with memory. It can help if the system is thrashing but not much. Setting maximum memory for individual sessions doesn't help if there are too many sessions. – Gilles Nov 2 '16 at 22:11
  • How about imposing resource limitation upon the whole user.slice unit, which umbrella all user sessions without interfering system.slice? – Yun-Chih Chen Nov 2 '16 at 23:59
  • Yes, that would work, if you run sshd outside of that slice. – Gilles Nov 3 '16 at 0:00
  • Indeed, sshd.service is usually in system.slice. – Yun-Chih Chen Nov 3 '16 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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