-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Horizontal Scaling #159
Horizontal Scaling #159
Conversation
👍👍 thanks
|
|
Ad b.1) One thing we should consider then, however, is that for e.g. a DB master, which we only scale vertically, we should then add a separate ingredient for horizontally scaled DB slaves. Overall, I think this approach (b.1) is very reasonable. If you agree I will go ahead and implement the changes in the model and the UI. We can implement more complex scaling scenarios (b.2, c) later if necessary. |
[DB master-slave] Agree, that special case would need some extra treatment. Yes, that's fine for me 👍👍 |
41950ec
to
c1c1e8c
Compare
A very interesting error on Wercker:
I am moderately confused. |
Mhmmm 🙃 |
Hm.. no. Apparently it's kind of reproducible. The second wercker build succeeded. Locally, it works fine with |
Hmm. Interesting. Well I guess then we blame Wercker and assume that it'll work... |
Agreed. I'll finish the UI tomorrow, then we can rebase and roll it out. On Wednesday, October 12, 2016, Joel Scheuner [email protected]
|
This PR is now ready for review. |
c1c1e8c
to
874cec5
Compare
874cec5
to
b4a81a6
Compare
b4a81a6
to
7b74651
Compare
I drafted a blog post to introduce the scaling policies: https://medium.com/cloud-stove/e1410f816b73 |
7b74651
to
32ec91c
Compare
f65ac5c
to
32ec91c
Compare
Seems to work well when I disable inter ingredient traffic, but is really slow if traffic is considered.
It will now parse as JSON object (with one empty ingredient at the top of the list).
It works fine for smallish ram and cpu constraints, but takes forever with big values (e.g., 100GB RAM).
Instead of finding the ideal combination among all resources per ingredient, we now search for the ideal number of resources from a single resource type to fulfill all constraints. With this simplification, recommendations are generated quickly.
The new model is a drop-in replacement for the original model, except for the additional ‘resource_count’ result.
Also, adjust model to make vCPUs integers again (i.e., vCPUs * 100).
Using `max_num_resources` you can limit the number of resources assigned to an ingredient. Set it to `0` for no restrictions. Currently, the model generated by the app does not yet contain a scaling constraint and just defaults to `0`.
The scaling constraint specifies the maximum number of instances allowed for any ingredient. The scaling workload is currently a boolean flag to indicate whether the ingredient should be scaled horizontally. The template seed ingredients already use the scaling constraint to keep the db master as a single instance with multiple horizontally scaled db slaves. To ease transition, `Ingredient#update_constraints` does not fail if no scaling workload exists. A default scaling workload that activates horizontal scaling is created instead (see `Ingredient#scaling_workload`).
32ec91c
to
1427e08
Compare
'regions' => region_codes, | ||
'vm_cost' => '475.42', | ||
'total_cost' => 475416 | ||
'total_cost' => 475419 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
total_cost
changed because the number of different resources in the recommendation is added to the costs as a tie-breaker.
For providers like Digital Ocean, where instance costs and specs scale exactly linearly, we have multiple "optimal" solutions and by adding the number of assigned resources to the costs we prefer recommendations with fewer resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Agree to prefer fewer solutions with fewer resources 👍
We should keep that in mind if we want to use total_cost
one day 😉
This PR should be ready. Please review and merge. /cc @joe4dev |
Copying an application set every ingredient to use the horizontal scaling scheme instead of mirroring the scheme of the copy template.
User authentication is done by the application controller by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it seems ok to me.
However, the Amazon recommendations for horizontal scaling do not behave the same as Google with regard to partial CPU cores. Google chooses f1-micro (5x) instances with 0.2 cores whereas Amazon always chooses m3.medium (1x), which is the smallest instance with a full CPU core.
It seems to me that Amazon instance with partial core count are not considered 😏
Comment about instance choice:
Obviously, horizontal scaling often chooses the weakest instances (e.g., f1-micro, basic-a0). This might sometimes not be suitable for production deployment.
@@ -0,0 +1,75 @@ | |||
class ScalingWorkloadsController < ApplicationController | |||
|
|||
before_action :authenticate_user! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed as already present in ApplicationController
(rationale: protect every endpoint by default to avoid security breaches when adding new controllers)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 770b13c
'regions' => region_codes, | ||
'vm_cost' => '475.42', | ||
'total_cost' => 475416 | ||
'total_cost' => 475419 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Agree to prefer fewer solutions with fewer resources 👍
We should keep that in mind if we want to use total_cost
one day 😉
I'm not sure if there is a problem with the recommendations, but Amazon Yes, horizontal scaling will always choose the smallest instance. Currently, I guess recommendations should include other instance types if RAM requirements are high (since specialized instances should be cheaper per GB RAM) and when CPU requirements are very high (since specialized instances should be cheaper per core). We could of course add a minimum RAM/CPU threshold to the workload to prevent these instance types from showing up in recommendations. Nevertheless, I would merge this PR now if there are no other issues. |
Agree 👍 |
Adds a new optimization model for horizontal scaling that replaces the original MiniZinc model.
It should replace the original MiniZinc model, but currently the original functionality is not yet mirrored.(Closes #156. Eventually.)While I initially wanted to have an unconstrained model that chooses the optimal combination and number of resources from all available instance types, I had to simplify the model to restrict recommendations per ingredient to one resource type and a multiplier (
num_resources
) representing the number of required instances. The original, unconstrained model is in the commit history for provenance. The unconstrained model unfortunately did not produce results in reasonable time, as the number of possible resource assignments grows unreasonably large for complex applications and large numbers of users.In addition to the new MiniZinc model, we now also represent partial CPU cores as reported by the providers (e.g., for the
t2.*
Amazon bursting instances and for Googlef1-
andg1-
). To accommodate this, CPU cores are represented as 1/100ths in the model.The output of the optimization is compatible with the original model, with the addition of a
num_resources
array that represents the number of instances required to fulfill the ingredient constraints.Things left to do/discuss
a) At recommendation generation time (i.e., when hitting 'generate recommendation'), we add a 'vertical/horizontal' checkbox. This would restore the original functionality and allow for the generation of purely vertically scaled recommendations. (but: While I think that these vertical scaling recommendations are educational to clearly see savings potential, I'm not sure we want to prominently show recommendations that basically consist of SPOFs for all ingredients).array[Ingredients] of bool: distribute_cpu;
andarray[Ingredients] of bool: distribute_ram;
to the optimization model. We update the model to restrict recommendations to resources that fulfill CPU and/or RAM constraints for ingredients withdistribute_[cpu|ram] == false
. With this approach, we could model ingredients that need, e.g., at least 1 GB of RAM for every instance and scale according to computed CPU constraints (also need to set RAM growth per user to 0 then, otherwise RAM requirement continues to grow).c) We add more complex scaling policies, e.g., minimum and maximum number of instances per ingredient, minimum RAM/CPU per instance. With this, we can model more complex deployments than currently possible with Cloudorado. We need to supply additional information to the model, such asarray[Ingredients] of var int: min_num_instances;
,array[Ingredients] of var int: max_num_instances;
,array[Ingredients] of var int: min_cpu_per_instance;
,array[Ingredients] of var int: min_ram_per_instance
. Overall ingredient constraints are computed as before; the 'per instance' fields would not change with the number of users. This would then allow to model constraints, such as, 'a PostgreSQL ingredient should have ≥2 instances, ≤5 instances, 12MB RAM per user, 1/2500th CPU per user, min 512MB RAM per instance, min 1 vCPU per instance'.Implementation summary
scaling_constraints
attached to ingredients with amax_number_of_instances
attribute to restrict the number of allowed instances per resource for generated recommendations (with0
for no restriction).