Difference between revisions of "Containers/Guarantees for resources"
m (force some math to be rendered as PNG →Providing a guarantee through limiting) |
|||
Line 85: | Line 85: | ||
} | } | ||
</pre> | </pre> | ||
+ | |||
+ | = Disadvantages of this approach = | ||
+ | |||
+ | This approach has the following disadvantages | ||
+ | |||
+ | # Lets consider initialization - When we create <math>n</math> groups initially, we need to spend <math>O(n^2)</math> time to assign guarantees. | ||
+ | # Everytime a limit or a guarantee changes, we need to recalculate guarantees to ensure that the change will not break any guarantees | ||
+ | # The same thing as stated above, when a resource group is created or deleted | ||
+ | |||
+ | This can lead to some instability, a change in one group propagates to all other groups. |
Revision as of 08:26, 18 September 2006
This page describes how guarantees for resources can be implemented.
How to guarantee a guarantee
It's not obvious at the first glance, but there are only two ways of how a guarantee can be provided:
- reserve desired amount in advance
- limit consumers to keep some amount free
The first way has the followong disadvantages:
- Reservation is impossible for certain resources
- such as CPU time, disk or network bandwidth and similar can not be just reserved as their amount instantly increases;
- Reserved amount is essentially a limit, but much more strict
- cutting off X megabytes from RAM implies that all the rest groups are limited in their RAM consumption;
- Reservation reduces containers density
- if one wants to run some identical containers, each requiring 100Mb on 1Gb system, reservations can be done for only 10 containers, and starting the 11th is impossible.
On the other hand, limiting of containers can provide guarantees for them as well.
Providing a guarantee through limiting
The idea of getting a guarantee is simple:
For groups in the system this implies solving a linear equation set to get limits like this:
In a matrix form this looks like
where
and thus the solution is
Skipping boring calculations, the reverse matrix is
This solutions looks huge, but the vector is calculated in time:
void calculate_limits(int N, int *g, int *l) { int sum; sum = 0; for (i = 0; i < N; i++) sum += g[i]; for (i = 0; i < N; i++) l[i] = sum - (R - g[i]) - (N - 2) * (R - g[i]); }
Disadvantages of this approach
This approach has the following disadvantages
- Lets consider initialization - When we create groups initially, we need to spend time to assign guarantees.
- Everytime a limit or a guarantee changes, we need to recalculate guarantees to ensure that the change will not break any guarantees
- The same thing as stated above, when a resource group is created or deleted
This can lead to some instability, a change in one group propagates to all other groups.