2

Question :

How can I limit the load average so it does not excess a certain number? I am on a debian 4.7 (wheezy).

Context :

I rented a vps some time ago (4 cores) so I can run some computations, but the company suspended my vps, pretexting that a load average of 3.5 was too much because they were sharing the nodes. They agreed to run it again as long as my average load doesn't excess 2.0. Besides the "legal" aspect of imposing constraint not referenced anywhere on their website, how can I achieve that?

For now I just reduced the parallelism of my application, but it is not easy to control because it spawns many child processes.

  • you might be able to write a supervising process that sends SIGSTOP and SIGCONT to busy processes to temporarily remove them from the run queue, but this will disrupt some system calls with EINTR (see man 7 signal). – meuh Jun 22 '16 at 9:58
  • load average is a poor indication of cpu usage. You might try asking to continue as before but only use 1 or 2 cpus. Use taskset to set the cpu affinity for your processes, and leave 2 cpus free for them. – meuh Jun 22 '16 at 10:02
3

Find another company. If they claim to rent you four cores, you should get four cores. A complaint that the load is 3.5 (which means you're using approximately three and a half cores, not four) and that it therefore is abusing their system, is ridiculous.

There are many cloud providers who will happily allow you to run whatever you want...

  • 1
    Also, imposing any kinds of limits should be the providers responsibility, not the customers. – Martin von Wittich Jun 21 '16 at 19:20
  • 1
    @MartinvonWittich -- exactly. If they can't do that, no telling what else they'll fail at. – Wouter Verhelst Jun 21 '16 at 19:20
  • I won't continue using their service, but since I already paid the month, I'm kinda held as an "hostage" for now... – Richard Jun 22 '16 at 0:48
  • You could ask for your money back. If they don't do that... there's no law which says you have to use what you paid for... – Wouter Verhelst Jun 22 '16 at 6:13
0

There are many ways you can throttle an application but the simplest is usually to add usleep() or similar calls to slow it down which in turn lowers the CPU usage.

Considering that your application spawns many processes, it may also be worthwhile to look at adjusting that part as well.

  • Thanks, but I don't want to limit one application, but the complete charge on the server. For example, if I spawn a mozilla, I wan't to reduce the activity of other processes. – Richard Jun 21 '16 at 6:02
  • The only way this could be generalized would be through a change in the scheduler inside the kernel and this is not possible on a VPS. Also keep in mind that the process scheduler is one of the most complex components of the kernel. – Julie Pelletier Jun 21 '16 at 6:23
  • The closest that you could do would be to write a script that pauses processes that have taken a lot of CPU but that may cause serious side-effects if done randomly. – Julie Pelletier Jun 21 '16 at 6:27

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.