Here in this post i will list sample code(not exact code but more like pseudo code) to explain how auto scaling components works. We can use this logic in scalable load balancers to take decisions based on number of requests.
required_instances = request_in_fly / number_of_max_requests_per_ instance;
if (required_instances > current_active_instance)
{
{
//This need scale up
if(required_instances < max_allowed)
{
{
spwan_inatances( required_instances - current_active_instance );
wait_sometime_to_activate_ instances();
}
else{
//Cannot handle load
}
}
}
else
{
{
//This is scale down decision
if(required_instances > min_allowed)
{
if(required_instances > min_allowed)
{
terminate_inatances( current_active_instance - required_instances );
wait_some_time_to_effect_ termination();
}
}
}
No comments:
Post a Comment