This repository was archived by the owner on Oct 13, 2023. It is now read-only.
# [FEATURE] AutoRange #148
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull-request is related to:
$ docker container statsformatWhat
AutoRange is a feature that helps to find and to apply the optimal limits for a service. It is an extension for the docker collector and require swarm mode to be enabled.
Why
This collector extension was thought as a way to monitor and predict the optimal consumption limits for a service. The goal was to find the point where a service could function properly, but still save as much resources as possible. It was written as a way to answer the question
How to optimize the number of services running on our infrastructure without losing quality of service?How
The logic behind the feature can be described in 3 points:
- First, we collect the metrics and apply some transformations on it to generate two values.
Those values represent a "box" around the actual consumption.
- Then, we transform these values into time-series, using some of the key data collected previously to
weight our operations. The amplitude of change between values is monitored to know if it's time to stop measurements.
- Finally, we obtain refined values that we apply as limitation to the service. The data are then kept in a reduced form to limit memory usage.
Usage
The functionality is declared by adding the
autorangekey to thedocker-compose.yml.The mechanism works for
cpu%andmemory, with or without base values.Below is an example of both.
The available keys are:
- min (in octets)
- max (in octets)
- threshold% (only for memory, represents a security margin that will be refined by the algorithm)
This functionality is deployed with
$ docker stack deploy --compose-file=/your/compose/fileand then$ docker container stats --format autorange(format is not necessary but shows the predicted values). Thedocker container statsis mandatory to start the collector. The collector needs to keep running to accumulate and predict values. You can always leave thedocker container statsscreen and come back later, the mechanism will be paused and the accumulated data won't be lost.Improvements
Thing that could be improved:
- Compatibility with
docker-compose, by removing the need for swarm labels.- Avoid running
$ docker container statsto start the collector, getting stats directly from the api.- Implement a trigger to re-ignite the mechanism, using the old values as bases to further refine the predictions, in case of a change in behavior.
I'm open to any suggestion on how to refine the code/feature to better suit the docker scheme.
Cute animal