Documentation
¶
Overview ¶
Package rightsizing is a deterministic, pure-Go engine that turns an app's historical CPU/memory usage into a resource-limit suggestion. It is a read-and-suggest layer on top of the platform API, per this project's AI design rule: it never calls an external model, never writes to any resource, and its output is never applied automatically. Every recommendation is backed by literal samples or a literal OOM signal it was given; when there isn't enough history yet, Recommend says so rather than guessing.
Index ¶
Constants ¶
const ( ConfidenceHigh = "high" ConfidenceMedium = "medium" ConfidenceLow = "low" )
Confidence levels a DimensionRecommendation can carry.
const ( ActionRaise = "raise" ActionLower = "lower" ActionKeep = "keep" )
Actions a DimensionRecommendation can suggest.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DimensionRecommendation ¶
type DimensionRecommendation struct {
Dimension string
SampleCount int
DataSufficient bool
Confidence string
CurrentLimit int64
P95Usage float64
P99Usage float64
SuggestedLimit int64
// Action is "" when there isn't enough data, or no limit is
// currently set, to responsibly suggest raising or lowering one.
Action string
Reason string
}
DimensionRecommendation is one resource dimension's (memory or CPU) suggestion.
type Input ¶
type Input struct {
ServiceName string
Now time.Time
LookbackWindow time.Duration
MemorySamples []Sample
CPUPercentSamples []Sample
CurrentMemoryBytes int64
CurrentNanoCPUs int64
OOM *OOMEvidence
}
Input bundles one app's usage history and current limits. CPUPercentSamples is Docker's own 0-100-per-core convention (internal/docker.ContainerStats. CPUPercent's own doc comment): a container fully using 2 cores reads 200, converted internally to nano-CPUs to compare against CurrentNanoCPUs.
type OOMEvidence ¶
OOMEvidence is a genuinely observed OOM-kill signal (a log line matching a known OOM pattern; see internal/diagnose.OOMLogPatterns), never fabricated from usage numbers alone.
type Result ¶
type Result struct {
ServiceName string
LookbackWindow time.Duration
Memory DimensionRecommendation
CPU DimensionRecommendation
OOM *OOMEvidence
}
Result is Recommend's output: one recommendation per dimension, plus whatever OOM evidence fed into the memory one.