Interface VerticalVmScaling
- All Superinterfaces:
VmScaling
- All Known Implementing Classes:
VerticalVmScalingAbstract,VerticalVmScalingSimple
DatacenterBroker to request the dynamic scale of
VM resources up or down, according to the current resource usage.
For each kind of resource to be scaled, a different VerticalVmScaling
instance should be provided.
If a scaling object is going to be set to a Vm, it has to be exclusive of that Vm.
Different Vms must have different instances of a scaling object.
A Vm runs a set of Cloudlets. When a VerticalVmScaling object
is attached to a Vm, it's required to define which
resource will be scaled (Ram, Bandwidth, etc)
when it's under or
overloaded.
The scaling request follows this path:
- a
Vm, which has aVerticalVmScalingobject set, monitors its own resource usage using anEventListener, to check if anunderoroverloadcondition is met; - if any of these conditions is met, the Vm uses the VerticalVmScaling
to send a scaling request to its
DatacenterBroker; - the DatacenterBroker forwards the request to the
Datacenterwhere the Vm is hosted; - the Datacenter delegates the task to its
VmAllocationPolicy; - the VmAllocationPolicy checks if there is resource availability and then finally scale the Vm.
WARNING
Make sure that the
UtilizationModel of some of these Cloudlets
is defined as ABSOLUTE. Defining the UtilizationModel
of all Cloudlets running inside the Vm as PERCENTAGE
causes these Cloudlets to automatically increase/decrease their resource usage when the
Vm resource is vertically scaled.
This is not a CloudSim Plus issue, but the natural and maybe
surprising effect that may trap researchers trying to implement and assess VM scaling policies.
Consider the following example: a VerticalVmScaling is attached to
a Vm to double its Ram when its usage reaches 50%.
The Vm has 10GB of RAM.
All Cloudlets running inside this Vm have a UtilizationModel
for their RAM utilization defined in PERCENTAGE.
When the RAM utilization of all these
Cloudlets reach 50% (5GB), the Vm Ram will be doubled.
However, as the RAM usage of the running Cloudlets is defined in percentage, they will
continue to use 50% of Vm's RAM, that now represents 10GB from the 20GB capacity.
This way, the vertical scaling will have no real benefit.
- Since:
- CloudSim Plus 1.1.0
- Author:
- Manoel Campos da Silva Filho
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final VerticalVmScalingAn attribute that implements the Null Object Design Pattern forVerticalVmScalingobjects. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTries to allocate more resources for a VM, if there is availability.longGets the current amount allocated to theresourcemanaged by this scaling object.Returns a Function that defines the lower utilization threshold for a Vm which indicates if it is underloaded or not.Returns the actual Vm Resource this scaling object is in charge of scaling.doubleReturns the absolute amount of the Vm resource which has to be scaled up or down.Class<? extends ResourceManageable> Returns the class of Vm resource that up or down scaling will be requested.Gets the lower or upper resource utilization thresholdFunction, depending on if the Vm resource is under or overloaded, respectively.doubleReturns the factor that will be used to scale a Vm resource up or down, whether such a resource is over or underloaded, according to the defined predicates.Returns a Function that defines the upper utilization threshold for a Vm which indicates if it is overloaded or not.booleanReturns true if the Vm is overloaded, false otherwise.booleanReturns true if the Vm is underloaded, false otherwise.voidvoidbooleanPerforms a vertical scale if the Vm is overloaded, according to thegetUpperThresholdFunction()predicate, increasing the Vm resource to which the scaling object is linked to (that may be RAM, CPU, BW, etc.), according to thescaling factor.setLowerThresholdFunction(Function<Vm, Double> lowerThresholdFunction) setResourceScaling(ResourceScaling resourceScaling) Sets theResourceScalingthat defines how the resource has to be resized.setScalingFactor(double scalingFactor) Sets the factor that will be used to scale a Vm resource up or down, whether such a resource is over or underloaded, according to the defined predicates.setUpperThresholdFunction(Function<Vm, Double> upperThresholdFunction)
-
Field Details
-
NULL
An attribute that implements the Null Object Design Pattern forVerticalVmScalingobjects.
-
-
Method Details
-
getResourceClass
Class<? extends ResourceManageable> getResourceClass()Returns the class of Vm resource that up or down scaling will be requested. Such a class can beRam,BandwidthorPe.- Returns:
- the class of Vm resource that up or down scaling will be requested
- See Also:
-
getScalingFactor
double getScalingFactor()Returns the factor that will be used to scale a Vm resource up or down, whether such a resource is over or underloaded, according to the defined predicates.If the resource to scale is a
Pe, this is the absolute number of PEs to request adding or removing when the VM is over or underloaded, respectively. For any other kind of resource, this is a percentage value in scale from 0 to 1. Every time the VM needs to be scaled up or down, this factor will be applied to increase or decrease a specific VM allocated resource.- Returns:
- the factor that will be used to scale a Vm resource up or down, whether such a resource is over or underloaded, according to the defined predicates
- See Also:
-
setScalingFactor
Sets the factor that will be used to scale a Vm resource up or down, whether such a resource is over or underloaded, according to the defined predicates.If the resource to scale is a
Pe, this is the absolute number of PEs to request adding or removing when the VM is over or underloaded, respectively. For any other kind of resource, this is a percentage value in scale from 0 to 1. Every time the VM needs to be scaled up or down, this factor will be applied to increase or decrease a specific VM allocated resource.- Parameters:
scalingFactor- the scaling factor to set which may be an absolute value (forPescaling) or percentage (for scaling other resources)- Returns:
- this VerticalVmScaling object
- See Also:
-
getResourceUsageThresholdFunction
Gets the lower or upper resource utilization thresholdFunction, depending on if the Vm resource is under or overloaded, respectively.- Returns:
- the lower resource utilization threshold function if the Vm resource is underloaded; upper resource utilization threshold function if the Vm resource is overloaded; or a function that always returns 0 if the Vm isn't in any of these conditions.
- See Also:
-
isVmUnderloaded
boolean isVmUnderloaded()Returns true if the Vm is underloaded, false otherwise. That is based on thegetLowerThresholdFunction().- Returns:
- true if the Vm is underloaded, false otherwise
-
isVmOverloaded
boolean isVmOverloaded()Returns true if the Vm is overloaded, false otherwise. That is based on thegetUpperThresholdFunction().- Returns:
- true if the Vm is overloaded, false otherwise
-
getResource
Resource getResource()Returns the actual Vm Resource this scaling object is in charge of scaling.- Returns:
- the actual Vm Resource this scaling object is in charge of scaling
-
getResourceAmountToScale
double getResourceAmountToScale()Returns the absolute amount of the Vm resource which has to be scaled up or down. That is based on thescaling factor.- Returns:
- the absolute amount of the Vm resource which has to be scaled up or down
- See Also:
-
requestUpScalingIfPredicateMatches
Performs a vertical scale if the Vm is overloaded, according to thegetUpperThresholdFunction()predicate, increasing the Vm resource to which the scaling object is linked to (that may be RAM, CPU, BW, etc.), according to thescaling factor.The time interval in which it will be checked if the Vm is overloaded depends on the
Datacenter.getSchedulingInterval()value. Make sure to set such a value to enable the periodic overload verification.- Specified by:
requestUpScalingIfPredicateMatchesin interfaceVmScaling- Parameters:
evt- event information containing the Vm to be scaled- Returns:
- true if the Vm is over or underloaded and up or down scaling request was sent to the broker; false otherwise
- See Also:
-
getUpperThresholdFunction
Returns a Function that defines the upper utilization threshold for a Vm which indicates if it is overloaded or not. If it is overloaded, the Vm'sDatacenterBrokerwill request to up scale the VM. The up scaling is performed by increasing the amount of theresourcethe scaling is associated to.This function must receive a
Vmand return the upper utilization threshold for it as a percentage value between 0 and 1 (where 1 is 100%). The VM will be defined as overloaded if the utilization of theResourcethis scaling object is related to is higher than the value returned by theFunctionreturned by this method.- Returns:
- a Function that defines the upper utilization threshold for a Vm which indicates if it is overloaded or not
- See Also:
-
setUpperThresholdFunction
Sets aFunctionthat defines the upper utilization threshold for aVmwhich indicates if it is overloaded or not. If it is overloaded, the Vm'sDatacenterBrokerwill request to up scale the VM. The up scaling is performed by increasing the amount of theresourcethe scaling is associated to.This function must receive a
Vmand return the upper utilization threshold for it as a percentage value between 0 and 1 (where 1 is 100%).By setting the upper threshold as a
Functioninstead of a directly storing aDoublevalue which represent the threshold, it is possible to define the threshold dynamically instead of using a static value. Furthermore, the threshold function can be reused for scaling objects of different VMs. -
getLowerThresholdFunction
Returns a Function that defines the lower utilization threshold for a Vm which indicates if it is underloaded or not. If it is underloaded, the Vm'sDatacenterBrokerwill request to down scale the VM. The down scaling is performed by decreasing the amount of theresourcethe scaling is associated to.This function must receive a
Vmand return the lower utilization threshold for it as a percentage value between 0 and 1 (where 1 is 100%). The VM will be defined as underloaded if the utilization of theResourcethis scaling object is related to is lower than the value returned by theFunctionreturned by this method.- Returns:
- a Function that defines the lower utilization threshold for a Vm which indicates if it is underloaded or not
- See Also:
-
setLowerThresholdFunction
Sets aFunctionthat defines the lower utilization threshold for aVmwhich indicates if it is underloaded or not. If it is underloaded, the Vm'sDatacenterBrokerwill request to down scale the VM. The down scaling is performed by decreasing the amount of theresourcethe scaling is associated to.This function must receive a
Vmand return the lower utilization threshold for it as a percentage value between 0 and 1 (where 1 is 100%). By setting the lower threshold as aFunctioninstead of a directly storing aDoublevalue which represent the threshold, it is possible to define the threshold dynamically instead of using a static value. Furthermore, the threshold function can be reused for scaling objects of different VMs. -
setResourceScaling
Sets theResourceScalingthat defines how the resource has to be resized.- Parameters:
resourceScaling- theResourceScalingto set- Returns:
- this VerticalVmScaling object
-
getAllocatedResource
long getAllocatedResource()Gets the current amount allocated to theresourcemanaged by this scaling object. It is just a shortcut togetVmResourceToScale.getAllocatedResource().- Returns:
- the amount of allocated resource
-
allocateResourceForVm
boolean allocateResourceForVm()Tries to allocate more resources for a VM, if there is availability.- Returns:
- true if resources were allocated to the VM, false otherwise
-
logDownscaleToZeroNotAllowed
void logDownscaleToZeroNotAllowed()
-