2

So this is my first time posting on Ubuntu forums, so please excuse me if this question is repetitive, or just plain stupid.

A bit of background: I am a 14yr old developer, who has an ubuntu 20.04 server. I started a small hosting service and we racked up quite a bit of clients. Now, we have a pricing model, like certian users can only get 1vCPU and 4GB Ram, while other users can have 6vCPUs and 20GB Ram For $80 Per 6 Months.

My Problem: I cannot limit how many vCPUs and RAM a user can get. I tried programs like cgroups, but when I checked how much ram a user had by free -m, the server returned to me 24GB (How Much Memory On The VM).

My Question: Is there a proper way to limit a specific user's RAM and vCPU usage? Preferably, if you could give me a guide that would be perfect! Thanks in advance for any help you can offer!

Making Some Progress: With cgroup, I can limit a specific user's CPU usage (/sys/fs/cgroup/user.slice/user-USERID.slice). In here, I can edit the cpu.cfs_quota_us, but this only limits CPU Percentage. Also a weird thing for me, when I do cat cpu.cfs_quota_us I get 200000? Isnt that 200%? I thought the default value for max was 101000? Still my main question is, how can I limit each user's core count, and memory?

More Progress: according to redhatguideforcgroup instead of using the cpu directory, the cpuset directory manages Multicore which is what I think I need.

Now IK I am getting close. While in the /sys/fs/cgroup/cpuset DIR I can run cat cpuset.cpus and that returns to me 0-5 (which is all the 6 cores I have present on my VM). Now if someone who knows basic cgroups (v2) can help me out to how I can set that to a specific user, I would appreciate that. this helped me

Mihir Garg
  • 23
  • 3
  • Have you considered using a job scheduler such as SLURM? – Ray Mar 12 '21 at 05:57
  • @Ray That Looks Promising, however, since I offer hosting, my clients need to be able to SSH into their made user. – Mihir Garg Mar 12 '21 at 06:00
  • This isn't Ubuntu Forums (https://ubuntuforums.org/) so is there a reason why you're mentioning the Ubuntu Forums? – guiverc Mar 12 '21 at 06:16
  • My bad, is this the wrong location for this? – Mihir Garg Mar 12 '21 at 06:19
  • Welcome to Ask Ubuntu. This is a Q&A site for Ubuntu and its official flavors, and your question is certainly on topic on this site. Ubuntu Forums is another website. – Archisman Panigrahi Mar 12 '21 at 06:23
  • Thanks, appreciate it. I am looking at cgroup again, is it possible to limit a specific user's usage with that? Currently looking at [link](https://www.youtube.com/watch?v=z7mgaWqiV90) – Mihir Garg Mar 12 '21 at 06:25
  • If you'd edited your question to remove reference to the other UF site, I'd have removed my comment :) – guiverc Mar 12 '21 at 06:39
  • At this point, I am not sure what programs to use or not. It seems like cgroups is good, and I found a tutorial to limit total CPU %, but not total CPU Core Count. – Mihir Garg Mar 12 '21 at 07:01
  • Does each user have a VM allocated to them? I believe SLURM supports VMs, but I don't know how to do that. But yes, they will ssh into your server and submit jobs. You should try configuring it -- that's probably the best way to understand what a job scheduler (i.e., SLURM isn't the only one out there) does. – Ray Mar 12 '21 at 08:07
  • @Ray No, multiple users share 1 VM, but I will checkout SLURM out! – Mihir Garg Mar 12 '21 at 08:09

0 Answers0