OpenVZ Forum


Home » General » Support » Setting up a load cap for a container: is this possible?
Setting up a load cap for a container: is this possible? [message #52056] Wed, 20 May 2015 09:24 Go to next message
fabioganga is currently offline  fabioganga
Messages: 3
Registered: May 2015
Location: Tenerife
Junior Member
Dear friends,

I am running a server with SolusVM (1 master + 3 slaves).

Quite often I have problems with individual containers having sudden peaks of high load (in one case, one container even reached over 2,000 which is totally unacceptable!).

I'm looking for a way (if at all possible) to set up a load cap for containers, so as not o have problems of any of them affecting the global performance of the node.

I don't want the container suspended if the cap is exceeded, it should just be a cap that cannot be exceeded.

Is this at all possible? I know it's not possible from within SolusVM, is there any workaround?

I need to resolve this problem, what is your best suggestion?

Thanks!
Re: Setting up a load cap for a container: is this possible? [message #52057 is a reply to message #52056] Wed, 20 May 2015 17:09 Go to previous messageGo to next message
Paparaciz
Messages: 302
Registered: August 2009
Senior Member
write some script which monitors containers and if needed set some low limits for particular container.

if it is the same container everytime, just set lower limits so that it will not affect other containers in case of problem.

check cpuunits limit. I don't know is it working or no, but maybe it can help
Re: Setting up a load cap for a container: is this possible? [message #52069 is a reply to message #52056] Fri, 29 May 2015 14:04 Go to previous messageGo to next message
speedbus is currently offline  speedbus
Messages: 4
Registered: May 2015
Junior Member
Checkout: It stops the VPS once it crosses the maxload (which is 10 in this case), you can change the vzctl stop command to vzctl restart as well

#! /bin/bash
export PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
maxload="10"; # put here the max loadavg permitted
cat /dev/null > loads.txt;
vzlist -o ctid,laverage > loads.txt;
cat loads.txt | while read line; do
vm=$(echo ${line:0:5});
load=$(echo ${line} | cut -d'/' -f3);
load2=$(echo ${load} | cut -d'.' -f1);
if [ $load2 -gt $maxload ]
    then
    echo "stopping $vm - $load";
    vzctl stop $vm;
    echo "$vm - $load" | mail -s "$vm stopped for overload" your@email.com
fi
done
Re: Setting up a load cap for a container: is this possible? [message #52070 is a reply to message #52069] Fri, 29 May 2015 16:39 Go to previous messageGo to next message
fabioganga is currently offline  fabioganga
Messages: 3
Registered: May 2015
Location: Tenerife
Junior Member
speedbus wrote on Fri, 29 May 2015 14:04
Checkout: It stops the VPS once it crosses the maxload (which is 10 in this case), you can change the vzctl stop command to vzctl restart as well

#! /bin/bash
export PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
maxload="10"; # put here the max loadavg permitted
cat /dev/null > loads.txt;
vzlist -o ctid,laverage > loads.txt;
cat loads.txt | while read line; do
vm=$(echo ${line:0:5});
load=$(echo ${line} | cut -d'/' -f3);
load2=$(echo ${load} | cut -d'.' -f1);
if [ $load2 -gt $maxload ]
    then
    echo "stopping $vm - $load";
    vzctl stop $vm;
    echo "$vm - $load" | mail -s "$vm stopped for overload" your@email.com
fi
done


Thanks ever so much, you're a star!!!

Will this script apply globally to the entire node?

How often would you recommend it is run by cron job?

Thanks!
Re: Setting up a load cap for a container: is this possible? [message #52071 is a reply to message #52070] Fri, 29 May 2015 17:46 Go to previous messageGo to next message
speedbus is currently offline  speedbus
Messages: 4
Registered: May 2015
Junior Member
fabioganga wrote on Fri, 29 May 2015 16:39
speedbus wrote on Fri, 29 May 2015 14:04
Checkout: It stops the VPS once it crosses the maxload (which is 10 in this case), you can change the vzctl stop command to vzctl restart as well

#! /bin/bash
export PATH="/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
maxload="10"; # put here the max loadavg permitted
cat /dev/null > loads.txt;
vzlist -o ctid,laverage > loads.txt;
cat loads.txt | while read line; do
vm=$(echo ${line:0:5});
load=$(echo ${line} | cut -d'/' -f3);
load2=$(echo ${load} | cut -d'.' -f1);
if [ $load2 -gt $maxload ]
    then
    echo "stopping $vm - $load";
    vzctl stop $vm;
    echo "$vm - $load" | mail -s "$vm stopped for overload" your@email.com
fi
done


Thanks ever so much, you're a star!!!

Will this script apply globally to the entire node?

How often would you recommend it is run by cron job?

Thanks!


>>Thanks ever so much, you're a star!!!
You're welcome Smile

>> Will this script apply globally to the entire node?
Yup, it'll apply to the whole node, each and every VPS on the node.

>> How often would you recommend it is run by cron job?
Run it every 5 minutes
Re: Setting up a load cap for a container: is this possible? [message #52074 is a reply to message #52069] Sun, 31 May 2015 16:37 Go to previous messageGo to next message
fabioganga is currently offline  fabioganga
Messages: 3
Registered: May 2015
Location: Tenerife
Junior Member
Thanks again speedbus.

I have tried launching the script manually to test it, and I get this error:

[root@servervps7 scripts]# sh antiload.sh
antiload.sh: line 10: [: too many arguments

line 10 is as follows in your script:

if [ $load2 -gt $maxload ]

What could the problem be? I love the idea of using your script!

Thanks!

Fabio
Re: Setting up a load cap for a container: is this possible? [message #52081 is a reply to message #52074] Tue, 02 June 2015 12:36 Go to previous message
speedbus is currently offline  speedbus
Messages: 4
Registered: May 2015
Junior Member
Hmmm, I had used this script a while back, it didn't error back then :/ Not too sure what it could be Sad
Previous Topic: yum update fails
Next Topic: How to boot in openVZ kernel while having multiboot OS
Goto Forum:
  


Current Time: Thu Mar 28 11:49:50 GMT 2024

Total time taken to generate the page: 0.01663 seconds