Доработать инструменты экспериментов: чередовать повторы, останавливать лестницу на первой проваленной ступени, задавать maxconn и CPU базы в сериях, записывать замер скорости хоста и контроль шума, сократить комментарии

This commit is contained in:
2026-11-04 12:39:04 +03:00
parent ce47c138e4
commit baa5995938
24 changed files with 253 additions and 240 deletions
+15 -10
View File
@@ -12,11 +12,17 @@ import (
"time"
)
// maxValidLag is the generator's own tolerance: if requests left more than
// this late at the 99th percentile, the generator, not the system, limited
// the step, and the step is excluded from the conclusions.
// maxValidLag: if requests left later than this at p99, the generator, not
// the system, limited the step.
const maxValidLag = 10 * time.Millisecond
// The capacity criterion of the study: a step passes when it is valid, has
// fewer than 1 % errors and its successful requests have a p99 within 500 ms.
const (
maxErrorShare = 0.01
sloP99 = 500 * time.Millisecond
)
// sample is one request as the generator saw it.
type sample struct {
planned time.Time
@@ -27,11 +33,9 @@ type sample struct {
write bool
}
// classify names the outcome of a request. HTTP errors produced by the
// balancer itself carry no X-Instance-Id and are kept apart from the API's
// own: a 503 from HAProxy means no replica was available, a 503 from the API
// means a dependency was. client_timeout is the generator giving up on a
// response, not a timeout of the system.
// classify names the outcome of a request. Errors of the balancer itself carry
// no X-Instance-Id and get the suffix _lb; client_timeout is the generator
// giving up, not a timeout of the system.
func classify(r result) string {
switch {
case r.err != nil && isTimeout(r.err):
@@ -78,12 +82,12 @@ type stepSummary struct {
P99Ms float64 `json:"ok_p99_ms"`
LagP99Ms float64 `json:"lag_p99_ms"`
Valid bool `json:"valid"`
Passed bool `json:"passed"`
Instances map[string]int `json:"instances"`
Writes int `json:"writes_ok"`
}
// summarize reduces one step. Latency percentiles cover successful requests
// only, as the course's report format asks; the errors are counted by class.
// summarize reduces one step; latency percentiles cover successful requests.
func summarize(rate float64, d time.Duration, samples []sample) stepSummary {
s := stepSummary{
OfferedRPS: rate,
@@ -117,6 +121,7 @@ func summarize(rate float64, d time.Duration, samples []sample) stepSummary {
lagP99 := percentile(lags, 99)
s.LagP99Ms = ms(lagP99)
s.Valid = lagP99 <= maxValidLag
s.Passed = s.Valid && s.ErrorShare < maxErrorShare && percentile(ok, 99) <= sloP99
return s
}