Ubuntu 20.04 disable cpu core?

edited May 1 in Help

Hello guys,

I do have a vps with 3 cores which I am allowed to use 75% 24/7. So I thought disabling one of the 3 cores to max out 2 cores 24/7 would be my way to go.

I tried to disable one core by editing the /etc/default/grub and adding maxcpus=2 but after running update-grub and restarting the cpu2 is still online.

Is there anything differnt in newer ubuntu versions so this method does not work?

Thanks in advance.

Comments

  • ehabehab Content Writer

    with your last setting , did you try to make a workload that uses all cpu and check from htop what is being used?

  • @ehab said:
    with your last setting , did you try to make a workload that uses all cpu and check from htop what is being used?

    No, I just checked htop to see how many cpus are avaible and took a look at /sys/devices/system/cpu/cpu2/online if it's online. Did not think of it might show up but is not being used.

  • @Multi_ said:
    I do have a vps with 3 cores which I am allowed to use 75% 24/7. So I thought disabling one of the 3 cores to max out 2 cores 24/7 would be my way to go.

    420 special, isn't it?
    https://talk.lowendspirit.com/discussion/comment/62861/#Comment_62861

    @Multi_ said:
    took a look at /sys/devices/system/cpu/cpu2/online if it's online.

    Do you know you can write to this file?
    Write a 0 and the CPU is offline.

    Thanked by (2)Multi_ ehab

    The end is nigh for Ubuntu 16.04. Providers still offering Ubuntu 16.04 past EOL will be ashamed.

  • BochiBochi OG
    edited May 1

    If it is a single process, that is producing the load you could use taskset to set its affinity.
    Or create a cpu cgroup with some limits for a whole set of processes and its threads, maybe even in combination with a cpuset.

    Thanked by (2)Multi_ ehab
  • @yoursunny said:

    @Multi_ said:
    I do have a vps with 3 cores which I am allowed to use 75% 24/7. So I thought disabling one of the 3 cores to max out 2 cores 24/7 would be my way to go.

    420 special, isn't it?
    https://talk.lowendspirit.com/discussion/comment/62861/#Comment_62861

    Yes, exactly.

    @Multi_ said:
    took a look at /sys/devices/system/cpu/cpu2/online if it's online.

    Do you know you can write to this file?
    Write a 0 and the CPU is offline.

    I can do that, but after a restart it's online again.

  • ehabehab Content Writer

    @Multi_ said:
    I can do that, but after a restart it's online again.

    google sysctl.d

    Thanked by (2)Multi_ skorous
  • @ehab said:

    @Multi_ said:
    I can do that, but after a restart it's online again.

    google sysctl.d

    Sorry for the late reply.

    I am unable to set the amount of cpu cores with a sysctl config. According to this list the "maxcpus" parameter is a kernel parameter but I am unable to use that in a config.

    I am really sorry but I am kinda new to the topic Kernels and their parameters. Until now it just worked for me ^^

  • Are you sure you're allowed to max 75% of all 3 cores? Linux tends to list cpu usage as percentage of a single core, ie maxing out 2 cores would result in 200% cpu usage.

    Could be that your provider has (rightfully so in my opinion) put the limit below 1 core all the time, since it's a shared environment.

    Thanked by (1)Ouji

    Hey teamacc. You're a dick. (c) Jon Biloh, 2020.

  • InceptionHostingInceptionHosting Hosting ProviderOG
    edited May 2

    @teamacc said:
    Are you sure you're allowed to max 75% of all 3 cores? Linux tends to list cpu usage as percentage of a single core, ie maxing out 2 cores would result in 200% cpu usage.

    Could be that your provider has (rightfully so in my opinion) put the limit below 1 core all the time, since it's a shared environment.

    If I had €1 for every time I have had to explain that.... well I would not be a millionaire but it would be a good chunk of change..

    People are so quick to look for loopholes to get dedicated resources on a shared resource environment.

    If the host wanted to they will just kill your cpu weight in the back end anyway I guess

    Maybe just ask your host to remove a core for you? If you are confident that is what you paid for it should not be a problem right?

    Thanked by (1)Multi_

    https://inceptionhosting.com
    Please do not use the PM system here for Inception Hosting support issues.

  • edited May 2

    @Multi_ said:

    @Multi_ said:
    took a look at /sys/devices/system/cpu/cpu2/online if it's online.

    @yoursunny said:
    Do you know you can write to this file?
    Write a 0 and the CPU is offline.

    I can do that, but after a restart it's online again.

    Create a custom systemd service to write the file upon start, and make that service auto start.


    @teamacc said:
    Are you sure you're allowed to max 75% of all 3 cores? Linux tends to list cpu usage as percentage of a single core, ie maxing out 2 cores would result in 200% cpu usage.

    Terms of Service for 420 special: https://hosterlabs.net/tos/
    Archive link: http://web.archive.org/web/20210420230451/https://hosterlabs.net/tos/

    "CPU Abuse is defined as: You might not use more than 75% of a shared CPU resource for more than 72 hours in a given week or 6 straight hours."

    This applies to every plan.
    It's only reasonable to interpret as "75% of all cores", otherwise there would be no difference paying for 1 core or 6 cores.

    Moreover, the provider themselves said "technically yes" when I asked: https://talk.lowendspirit.com/discussion/comment/62863/#Comment_62863


    @InceptionHosting said:
    People are so quick to look for loopholes to get dedicated resources on a shared resource environment.

    If the host wanted to they will just kill your cpu weight in the back end anyway I guess

    I know.
    It's like docker run --cpus 0.02, and everything in the container slows to a crawl.
    Oracle Cloud and EUserv are definitely doing that.
    VirMach is probably doing that.

    I have no problem with that, and I even prefer a permanent throttling of every resource.
    I hate having to set CPU limits on every process myself, and still worry about a suspension hammer.

    Thanked by (1)Multi_

    The end is nigh for Ubuntu 16.04. Providers still offering Ubuntu 16.04 past EOL will be ashamed.

  • InceptionHostingInceptionHosting Hosting ProviderOG

    I read “a shared cpu resource” as a (singular) thread or core.

    I am not just saying that to take an opposing view, that is honestly how I understood it on initial reading so it needs some clarification IMO.

    https://inceptionhosting.com
    Please do not use the PM system here for Inception Hosting support issues.

Sign In or Register to comment.