Support speedtest autotuning on the server side (#3777)

This commit is contained in:
Krishna Srinivas
2021-09-14 23:29:49 -07:00
committed by GitHub
parent 56b22c37fc
commit 24456eb990
3 changed files with 72 additions and 54 deletions
+65 -51
View File
@@ -19,12 +19,12 @@ package cmd
import (
"context"
"encoding/json"
"fmt"
"time"
humanize "github.com/dustin/go-humanize"
"github.com/minio/cli"
json "github.com/minio/colorjson"
"github.com/minio/madmin-go"
"github.com/minio/mc/pkg/probe"
)
@@ -45,6 +45,10 @@ var adminSpeedtestFlags = []cli.Flag{
Usage: "number of concurrent requests per server",
Value: 32,
},
cli.BoolFlag{
Name: "verbose, v",
Usage: "Show per-server stats",
},
}
var adminSpeedtestCmd = cli.Command{
@@ -65,14 +69,56 @@ FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
EXAMPLES:
1. Run speedtest with default values, check '--help' for default values:
1. Run speedtest with autotuning the concurrency to figure out the maximum throughput and iops values:
{{.Prompt}} {{.HelpName}} myminio/
2. Run speedtest for 20seconds with object size of 128MiB, 32 concurrent requests per server:
{{.Prompt}} {{.HelpName}} --duration 20s --size 128MiB --concurrent 32 myminio/
2. Run speedtest for 20 seconds with object size of 128MiB, 32 concurrent requests per server:
{{.Prompt}} {{.HelpName}} myminio/ --duration 20s --size 128MiB --concurrent 32
`,
}
type speedTestResult madmin.SpeedTestResult
func (s speedTestResult) String() (msg string) {
msg += fmt.Sprintf("MinIO %s, %d servers, %d drives\n", s.Version, s.Servers, s.Disks)
if globalSpeedTestVerbose {
msg += "\n"
}
msg += fmt.Sprintf("PUT: %s/s, %d objs/s\n", humanize.IBytes(uint64(s.PUTStats.ThroughputPerSec)), s.PUTStats.ObjectsPerSec)
if globalSpeedTestVerbose {
for _, node := range s.PUTStats.Servers {
msg += fmt.Sprintf(" * %s:, %s/s, %d objs/s", node.Endpoint, humanize.IBytes(uint64(node.ThroughputPerSec)), node.ObjectsPerSec)
if node.Err != "" {
msg += " error: " + node.Err
}
msg += "\n"
}
}
if globalSpeedTestVerbose {
msg += "\n"
}
msg += fmt.Sprintf("GET: %s/s, %d objs/s\n", humanize.IBytes(uint64(s.GETStats.ThroughputPerSec)), s.GETStats.ObjectsPerSec)
if globalSpeedTestVerbose {
for _, node := range s.GETStats.Servers {
msg += fmt.Sprintf(" * %s:, %s/s, %d objs/s", node.Endpoint, humanize.IBytes(uint64(node.ThroughputPerSec)), node.ObjectsPerSec)
if node.Err != "" {
msg += " error: " + node.Err
}
msg += "\n"
}
}
return msg
}
func (s speedTestResult) JSON() string {
JSONBytes, e := json.MarshalIndent(s, "", " ")
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
return string(JSONBytes)
}
var globalSpeedTestVerbose bool
func mainAdminSpeedtest(ctx *cli.Context) error {
if len(ctx.Args()) != 1 {
cli.ShowCommandHelpAndExit(ctx, "speedtest", 1) // last argument is exit code
@@ -114,58 +160,26 @@ func mainAdminSpeedtest(ctx *cli.Context) error {
fatalIf(errInvalidArgument(), "concurrency cannot be '0' or negative")
return nil
}
results, e := client.Speedtest(ctxt, madmin.SpeedtestOpts{
globalSpeedTestVerbose = ctx.Bool("verbose")
autotune := false
if ctx.NumFlags() == 0 {
autotune = true
}
if ctx.NumFlags() == 2 && globalSpeedTestVerbose {
autotune = true
}
result, _ := client.Speedtest(ctxt, madmin.SpeedtestOpts{
Size: int(size),
Duration: duration,
Concurrency: concurrent,
Autotune: autotune,
})
if e != nil {
fatalIf(probe.NewError(e), "Unable to run speedtest")
return nil
}
if globalJSON {
buf, e := json.Marshal(results)
fatalIf(probe.NewError(e), "Unable to marshal into JSON results")
fmt.Println(string(buf))
return nil
}
uploads := uint64(0)
downloads := uint64(0)
for _, result := range results {
uploads += result.Uploads
downloads += result.Downloads
}
durationSecs := duration.Seconds()
uploadSpeed := humanize.IBytes(uploads * uint64(size) / uint64(durationSecs))
downloadSpeed := humanize.IBytes(downloads * uint64(size) / uint64(durationSecs))
fmt.Printf("Operation: PUT\n* Average: %s/s, %d objs/s\n\n",
uploadSpeed, uploads/uint64(durationSecs))
fmt.Printf("Throughput by host:\n")
for _, result := range results {
fmt.Printf(" * %s: Avg: %s/s, %d objs/s\n",
result.Endpoint,
humanize.IBytes(result.Uploads*uint64(size)/uint64(durationSecs)),
result.Uploads/uint64(durationSecs),
)
}
fmt.Printf("\nOperation: GET\n* Average: %s/s, %d objs/s\n\n",
downloadSpeed, downloads/uint64(durationSecs))
fmt.Printf("Throughput by host:\n")
for _, result := range results {
fmt.Printf(" * %s: Avg: %s/s, %d objs/s\n",
result.Endpoint,
humanize.IBytes(result.Downloads*uint64(size)/uint64(durationSecs)),
result.Downloads/uint64(durationSecs),
)
}
fmt.Println()
printMsg(speedTestResult(result))
return nil
}
+1 -1
View File
@@ -16,7 +16,7 @@ require (
github.com/minio/cli v1.22.0
github.com/minio/colorjson v1.0.1
github.com/minio/filepath v1.0.0
github.com/minio/madmin-go v1.1.0
github.com/minio/madmin-go v1.1.5
github.com/minio/md5-simd v1.1.1 // indirect
github.com/minio/minio-go/v7 v7.0.13-0.20210819151058-7877ed5b8110
github.com/minio/pkg v1.0.10
+6 -2
View File
@@ -260,8 +260,12 @@ github.com/minio/colorjson v1.0.1/go.mod h1:oPM3zQQY8Gz9NGtgvuBEjQ+gPZLKAGc7T+kj
github.com/minio/filepath v1.0.0 h1:fvkJu1+6X+ECRA6G3+JJETj4QeAYO9sV43I79H8ubDY=
github.com/minio/filepath v1.0.0/go.mod h1:/nRZA2ldl5z6jT9/KQuvZcQlxZIMQoFFQPvEXx9T/Bw=
github.com/minio/madmin-go v1.0.12/go.mod h1:BK+z4XRx7Y1v8SFWXsuLNqQqnq5BO/axJ8IDJfgyvfs=
github.com/minio/madmin-go v1.1.0 h1:Y7YOPQafIVBpW0kwYzlt7FGi0GV23dlr/u3jRRrB4cw=
github.com/minio/madmin-go v1.1.0/go.mod h1:4nl9hvLWFnwCjkLfZSsZXEHgDODa2XSG6xGlIZyQ2oA=
github.com/minio/madmin-go v1.0.20 h1:gb3zY97oUuBuw6BTxmn2THhiEXEgSRmSVqhhHZq3Pc0=
github.com/minio/madmin-go v1.0.20/go.mod h1:4nl9hvLWFnwCjkLfZSsZXEHgDODa2XSG6xGlIZyQ2oA=
github.com/minio/madmin-go v1.1.1 h1:UyowiXN7FXBeoblQ0DCfpvcxeH+ik66XVbQfknTgJSY=
github.com/minio/madmin-go v1.1.1/go.mod h1:4nl9hvLWFnwCjkLfZSsZXEHgDODa2XSG6xGlIZyQ2oA=
github.com/minio/madmin-go v1.1.5 h1:xfzHwQ/KeKDQZKLqllNSyexwOPM/tvc13UdCeVMzADY=
github.com/minio/madmin-go v1.1.5/go.mod h1:xIPJHUbyYhNDgeD9Wov5Fz5/p7DIW0u+q6Rs/+Xu2TM=
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
github.com/minio/md5-simd v1.1.1 h1:9ojcLbuZ4gXbB2sX53MKn8JUZ0sB/2wfwsEcRw+I08U=
github.com/minio/md5-simd v1.1.1/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=