You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by Reka Thirunavukkarasu <re...@wso2.com> on 2014/12/21 08:48:19 UTC

Clarification on instanceRange check in RuleTaskDelegator

Hi Lahiru,

I saw the following code when calculating required instances. Since it is
checking the instanceRange > 0, whenever the cluster instance reaches it
maximum, this instanceRange is 0. At that point even though the load is
high no decision is taken as the required instances is not getting
calculated. Also, it is not notifying the parent as well even though it is
max out.

Shall we remove this check which will help to predict the required
instances even when the max is reached. So that we can notify the parent
about the max out.

Thanks,
Reka

-- 
Reka Thirunavukkarasu
Senior Software Engineer,
WSO2, Inc.:http://wso2.com,
Mobile: +94776442007

Re: Clarification on instanceRange check in RuleTaskDelegator

Posted by Reka Thirunavukkarasu <re...@wso2.com>.
Please find the code segment as below:

public int getNumberOfInstancesRequiredBasedOnMemoryConsumption(float
threshold, double predictedValue,
                                                                    int
max, int min) {
        double numberOfAdditionalInstancesRequired = 0;
        if(predictedValue != threshold) {

            float scalingRange = 100 - threshold;
            int instanceRange = max - min;

          *  if(instanceRange != 0){*

                float gradient = scalingRange / instanceRange;
                numberOfAdditionalInstancesRequired = (predictedValue -
threshold) / gradient;
            }
        }
        return (int) Math.ceil(min + numberOfAdditionalInstancesRequired);
    }

On Sun, Dec 21, 2014 at 1:18 PM, Reka Thirunavukkarasu <re...@wso2.com>
wrote:

> Hi Lahiru,
>
> I saw the following code when calculating required instances. Since it is
> checking the instanceRange > 0, whenever the cluster instance reaches it
> maximum, this instanceRange is 0. At that point even though the load is
> high no decision is taken as the required instances is not getting
> calculated. Also, it is not notifying the parent as well even though it is
> max out.
>
> Shall we remove this check which will help to predict the required
> instances even when the max is reached. So that we can notify the parent
> about the max out.
>
> Thanks,
> Reka
>
> --
> Reka Thirunavukkarasu
> Senior Software Engineer,
> WSO2, Inc.:http://wso2.com,
> Mobile: +94776442007
>
>
>


-- 
Reka Thirunavukkarasu
Senior Software Engineer,
WSO2, Inc.:http://wso2.com,
Mobile: +94776442007

Re: Clarification on instanceRange check in RuleTaskDelegator

Posted by Reka Thirunavukkarasu <re...@wso2.com>.
Thanks Lahiru for looking into this..yah..+1 for the above fix..

Thanks,
Reka

On Sun, Dec 21, 2014 at 4:30 PM, Lahiru Sandaruwan <la...@wso2.com> wrote:

> I think we can solve it better by adding an "else" part to the logic,
>
> We can increase the required number instance by one in the case of
> "max=min". Then it will send the maxOut event in rule evaluation since it
> is checked already. I'll change the commit as follows,
>
> if(instanceRange != 0){
>
>     float gradient = scalingRange / instanceRange;
>     numberOfAdditionalInstancesRequired = (predictedValue - threshold) / gradient;
> } else {
>
>     if(predictedValue > threshold){
>         return  max + 1;
>     }
> }
>
> Thanks.
>
> On Sun, Dec 21, 2014 at 4:21 PM, Lahiru Sandaruwan <la...@wso2.com>
> wrote:
>
>> Hi Reka,
>>
>>
>> On Sun, Dec 21, 2014 at 1:18 PM, Reka Thirunavukkarasu <re...@wso2.com>
>> wrote:
>>
>>> Hi Lahiru,
>>>
>>> I saw the following code when calculating required instances. Since it
>>> is checking the instanceRange > 0, whenever the cluster instance reaches it
>>> maximum, this instanceRange is 0.
>>>
>>
>> We get the instance range from "max = min". If we remove this check, it
>> may divide a value from Zero, which will cause infinity(a very large value)
>> in Java.
>>
>> So IMO we should handle the the "max = min" case in drools file
>> separately. We can send the max out event if predicted value is higher than
>> threshold in this case. I will implement it.
>>
>> Thanks.
>>
>>> At that point even though the load is high no decision is taken as the
>>> required instances is not getting calculated. Also, it is not notifying the
>>> parent as well even though it is max out.
>>>
>>> Shall we remove this check which will help to predict the required
>>> instances even when the max is reached. So that we can notify the parent
>>> about the max out.
>>>
>>> Thanks,
>>> Reka
>>>
>>> --
>>> Reka Thirunavukkarasu
>>> Senior Software Engineer,
>>> WSO2, Inc.:http://wso2.com,
>>> Mobile: +94776442007
>>>
>>>
>>>
>>
>>
>> --
>> --
>> Lahiru Sandaruwan
>> Committer and PMC member, Apache Stratos,
>> Senior Software Engineer,
>> WSO2 Inc., http://wso2.com
>> lean.enterprise.middleware
>>
>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>
>>
>
>
> --
> --
> Lahiru Sandaruwan
> Committer and PMC member, Apache Stratos,
> Senior Software Engineer,
> WSO2 Inc., http://wso2.com
> lean.enterprise.middleware
>
> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>
>


-- 
Reka Thirunavukkarasu
Senior Software Engineer,
WSO2, Inc.:http://wso2.com,
Mobile: +94776442007

Re: Clarification on instanceRange check in RuleTaskDelegator

Posted by Lahiru Sandaruwan <la...@wso2.com>.
I think we can solve it better by adding an "else" part to the logic,

We can increase the required number instance by one in the case of
"max=min". Then it will send the maxOut event in rule evaluation since it
is checked already. I'll change the commit as follows,

if(instanceRange != 0){

    float gradient = scalingRange / instanceRange;
    numberOfAdditionalInstancesRequired = (predictedValue - threshold)
/ gradient;
} else {

    if(predictedValue > threshold){
        return  max + 1;
    }
}

Thanks.

On Sun, Dec 21, 2014 at 4:21 PM, Lahiru Sandaruwan <la...@wso2.com> wrote:

> Hi Reka,
>
>
> On Sun, Dec 21, 2014 at 1:18 PM, Reka Thirunavukkarasu <re...@wso2.com>
> wrote:
>
>> Hi Lahiru,
>>
>> I saw the following code when calculating required instances. Since it is
>> checking the instanceRange > 0, whenever the cluster instance reaches it
>> maximum, this instanceRange is 0.
>>
>
> We get the instance range from "max = min". If we remove this check, it
> may divide a value from Zero, which will cause infinity(a very large value)
> in Java.
>
> So IMO we should handle the the "max = min" case in drools file
> separately. We can send the max out event if predicted value is higher than
> threshold in this case. I will implement it.
>
> Thanks.
>
>> At that point even though the load is high no decision is taken as the
>> required instances is not getting calculated. Also, it is not notifying the
>> parent as well even though it is max out.
>>
>> Shall we remove this check which will help to predict the required
>> instances even when the max is reached. So that we can notify the parent
>> about the max out.
>>
>> Thanks,
>> Reka
>>
>> --
>> Reka Thirunavukkarasu
>> Senior Software Engineer,
>> WSO2, Inc.:http://wso2.com,
>> Mobile: +94776442007
>>
>>
>>
>
>
> --
> --
> Lahiru Sandaruwan
> Committer and PMC member, Apache Stratos,
> Senior Software Engineer,
> WSO2 Inc., http://wso2.com
> lean.enterprise.middleware
>
> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>
>


-- 
--
Lahiru Sandaruwan
Committer and PMC member, Apache Stratos,
Senior Software Engineer,
WSO2 Inc., http://wso2.com
lean.enterprise.middleware

email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146

Re: Clarification on instanceRange check in RuleTaskDelegator

Posted by Lahiru Sandaruwan <la...@wso2.com>.
Hi Reka,


On Sun, Dec 21, 2014 at 1:18 PM, Reka Thirunavukkarasu <re...@wso2.com>
wrote:

> Hi Lahiru,
>
> I saw the following code when calculating required instances. Since it is
> checking the instanceRange > 0, whenever the cluster instance reaches it
> maximum, this instanceRange is 0.
>

We get the instance range from "max = min". If we remove this check, it may
divide a value from Zero, which will cause infinity(a very large value) in
Java.

So IMO we should handle the the "max = min" case in drools file separately.
We can send the max out event if predicted value is higher than threshold
in this case. I will implement it.

Thanks.

> At that point even though the load is high no decision is taken as the
> required instances is not getting calculated. Also, it is not notifying the
> parent as well even though it is max out.
>
> Shall we remove this check which will help to predict the required
> instances even when the max is reached. So that we can notify the parent
> about the max out.
>
> Thanks,
> Reka
>
> --
> Reka Thirunavukkarasu
> Senior Software Engineer,
> WSO2, Inc.:http://wso2.com,
> Mobile: +94776442007
>
>
>


-- 
--
Lahiru Sandaruwan
Committer and PMC member, Apache Stratos,
Senior Software Engineer,
WSO2 Inc., http://wso2.com
lean.enterprise.middleware

email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146