Доработать инструменты экспериментов: чередовать повторы, останавливать лестницу на первой проваленной ступени, задавать maxconn и CPU базы в сериях, записывать замер скорости хоста и контроль шума, сократить комментарии
This commit is contained in:
+16
-25
@@ -1,21 +1,10 @@
|
||||
// Command loadgen is the open-loop load generator of the scaling study
|
||||
// (track 1) and of the failover and rolling-update experiments.
|
||||
// Command loadgen is the open-loop load generator of the experiments.
|
||||
//
|
||||
// loadgen bench — seeds users, chats and messages, warms up, then offers
|
||||
// each rate of -rates for -step: a mix of history reads
|
||||
// (-read-ratio) and message sends. Writes steps.json and
|
||||
// seconds.csv, and metrics.jsonl with -scrape.
|
||||
// loadgen timeline — one user sends messages into one chat at -rate for
|
||||
// -duration; a send with an uncertain outcome (no answer,
|
||||
// 5xx) is retried with the same Idempotency-Key. At the
|
||||
// end the whole history is read back: every confirmed
|
||||
// message must be there, and none twice. Writes
|
||||
// timeline.json and seconds.csv.
|
||||
//
|
||||
// Requests are sent on schedule whatever the response times (open loop), and
|
||||
// the generator records how late it sent them: a step it could not keep up
|
||||
// with is marked invalid rather than reported as the system's limit. Tokens
|
||||
// stay in memory and are never written out.
|
||||
// loadgen bench — seeds data, warms up, then offers each rate of -rates
|
||||
// for -step as a mix of history reads and message sends.
|
||||
// loadgen timeline — one user sends messages at -rate, retrying uncertain
|
||||
// sends with the same Idempotency-Key, then reads the
|
||||
// history back: every confirmed message once.
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -52,6 +41,7 @@ type config struct {
|
||||
Timeout string `json:"client_timeout"`
|
||||
Seed uint64 `json:"seed"`
|
||||
Scrape bool `json:"scrape"`
|
||||
StopOnFail bool `json:"stop_on_fail"`
|
||||
StatsURL string `json:"stats_url"`
|
||||
APIHost string `json:"api_host"`
|
||||
DebugPort string `json:"debug_port"`
|
||||
@@ -98,6 +88,7 @@ func parse(mode string, args []string) (config, error) {
|
||||
fs.StringVar(&cfg.Duration, "duration", "60s", "timeline: duration")
|
||||
fs.StringVar(&cfg.Timeout, "timeout", "2s", "how long the generator waits for a response (class client_timeout)")
|
||||
fs.Uint64Var(&cfg.Seed, "seed", 1, "random seed of the request mix")
|
||||
fs.BoolVar(&cfg.StopOnFail, "stop-on-fail", false, "bench: end the ladder after the first step that fails the capacity criterion")
|
||||
fs.BoolVar(&cfg.Scrape, "scrape", false, "sample HAProxy statistics and replica expvar every second")
|
||||
fs.StringVar(&cfg.StatsURL, "stats-url", "http://lb:8404/;csv", "HAProxy statistics CSV")
|
||||
fs.StringVar(&cfg.APIHost, "api-host", "api", "DNS name of the API replicas")
|
||||
@@ -138,8 +129,7 @@ func writeJSON(path string, v any) error {
|
||||
return os.WriteFile(path, append(raw, '\n'), 0o644)
|
||||
}
|
||||
|
||||
// startScrape samples the system in the background when asked to; the
|
||||
// returned function stops it and waits.
|
||||
// startScrape returns the function that stops the sampling and waits.
|
||||
func startScrape(ctx context.Context, cfg config, start time.Time) func() {
|
||||
if !cfg.Scrape {
|
||||
return func() {}
|
||||
@@ -177,8 +167,7 @@ func runBench(ctx context.Context, cfg config) error {
|
||||
stopScrape := startScrape(ctx, cfg, start)
|
||||
defer stopScrape()
|
||||
|
||||
// next picks the request on the scheduling goroutine, where the random
|
||||
// source may be used safely.
|
||||
// next runs on the scheduling goroutine, which owns the random source.
|
||||
counter := 0
|
||||
next := func(rec *recorder) func(time.Time) func() {
|
||||
return func(planned time.Time) func() {
|
||||
@@ -217,8 +206,11 @@ func runBench(ctx context.Context, cfg config) error {
|
||||
for _, x := range rec.all() {
|
||||
all.add(x)
|
||||
}
|
||||
fmt.Printf("step %6.0f rps: ok %7.1f rps, errors %5.2f%%, p99 %7.1f ms, lag p99 %5.1f ms, valid %v\n",
|
||||
rate, s.OKRPS, 100*s.ErrorShare, s.P99Ms, s.LagP99Ms, s.Valid)
|
||||
fmt.Printf("step %6.0f rps: ok %7.1f rps, errors %5.2f%%, p99 %7.1f ms, lag p99 %5.1f ms, valid %v, passed %v\n",
|
||||
rate, s.OKRPS, 100*s.ErrorShare, s.P99Ms, s.LagP99Ms, s.Valid, s.Passed)
|
||||
if cfg.StopOnFail && !s.Passed {
|
||||
break
|
||||
}
|
||||
}
|
||||
stopScrape()
|
||||
if err := os.WriteFile(filepath.Join(cfg.Out, "seconds.csv"), []byte(secondsCSV(start, all.all())), 0o644); err != nil {
|
||||
@@ -247,8 +239,7 @@ type timelineReport struct {
|
||||
// retryDelay spaces the attempts of one message whose outcome was uncertain.
|
||||
const retryDelay = 200 * time.Millisecond
|
||||
|
||||
// retryGrace is how long after the schedule ends an uncertain message keeps
|
||||
// being retried before it counts as unresolved.
|
||||
// retryGrace bounds the retries of an uncertain message after the schedule ends.
|
||||
const retryGrace = 10 * time.Second
|
||||
|
||||
func runTimeline(ctx context.Context, cfg config) error {
|
||||
|
||||
Reference in New Issue
Block a user