docs: add usage for README.md (#76)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2024-11-01 14:57:48 +08:00
parent 2d7a7de23c
commit e2157f32cf
No known key found for this signature in database
GPG Key ID: 647A0EE86907F1AF
3 changed files with 110 additions and 7 deletions

View File

@ -2,11 +2,76 @@
This repository includes performance test tools of dragonfly.
## Directories
## Usage
### `/benchmark`
### Installation
Provide dragonfly performance test solution and related metics.
```shell
go install github.com/dragonflyoss/perf-tests/cmd/dfbench@latest
```
### Install Dragonfly for testing
Install Dragonfly using Helm chart, refer to [Dragonfly Helm Chart](https://d7y.io/docs/next/getting-started/installation/helm-charts/).
<!-- markdownlint-disable -->
```shell
$ helm repo add dragonfly https://dragonflyoss.github.io/helm-charts/
$ helm install --wait --create-namespace --namespace dragonfly-system dragonfly dragonfly/dragonfly
NAME: dragonfly
LAST DEPLOYED: Thu Apr 18 19:26:39 2024
NAMESPACE: dragonfly-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the scheduler address by running these commands:
export SCHEDULER_POD_NAME=$(kubectl get pods --namespace dragonfly-system -l "app=dragonfly,release=dragonfly,component=scheduler" -o jsonpath={.items[0].metadata.name})
export SCHEDULER_CONTAINER_PORT=$(kubectl get pod --namespace dragonfly-system $SCHEDULER_POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
kubectl --namespace dragonfly-system port-forward $SCHEDULER_POD_NAME 8002:$SCHEDULER_CONTAINER_PORT
echo "Visit http://127.0.0.1:8002 to use your scheduler"
2. Get the dfdaemon port by running these commands:
export DFDAEMON_POD_NAME=$(kubectl get pods --namespace dragonfly-system -l "app=dragonfly,release=dragonfly,component=dfdaemon" -o jsonpath={.items[0].metadata.name})
export DFDAEMON_CONTAINER_PORT=$(kubectl get pod --namespace dragonfly-system $DFDAEMON_POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
You can use $DFDAEMON_CONTAINER_PORT as a proxy port in Node.
3. Configure runtime to use dragonfly:
https://d7y.io/docs/getting-started/quick-start/kubernetes/
```
<!-- markdownlint-restore -->
Install file server for testing.
```shell
kubectl apply -f https://raw.githubusercontent.com/dragonflyoss/perf-tests/main/tools/file-server/file-server.yaml
```
### Run performance testing
```text
$ dfbench dragonfly
Running benchmark for all size levels by DFGET ...
+-----------------+-------+-------------+-------------+-------------+
| FILE SIZE LEVEL | TIMES | MIN COST | MAX COST | AVG COST |
+-----------------+-------+-------------+-------------+-------------+
| Nano(1B) | 3 | 528.46ms | 717.28ms | 648.17ms |
+-----------------+-------+-------------+-------------+-------------+
| Micro(1KB) | 3 | 691.76ms | 967.26ms | 798.55ms |
+-----------------+-------+-------------+-------------+-------------+
| Small(1MB) | 3 | 671.12ms | 1250.22ms | 897.32ms |
+-----------------+-------+-------------+-------------+-------------+
| Medium(10MB) | 3 | 716.83ms | 971.49ms | 816.14ms |
+-----------------+-------+-------------+-------------+-------------+
| Large(1GB) | 3 | 4855.28ms | 6069.76ms | 5526.63ms |
+-----------------+-------+-------------+-------------+-------------+
| XLarge(10GB) | 3 | 37428.71ms | 41206.96ms | 38794.96ms |
+-----------------+-------+-------------+-------------+-------------+
| XXLarge(30GB) | 3 | 102279.19ms | 139299.07ms | 118039.78ms |
+-----------------+-------+-------------+-------------+-------------+
```
## Community
@ -17,7 +82,6 @@ Join the conversation and help the community.
- **Developer Group**: <dragonfly-developers@googlegroups.com>
- **Github Discussions**: [Dragonfly Discussion Forum](https://github.com/dragonflyoss/Dragonfly2/discussions)
- **Twitter**: [@dragonfly_oss](https://twitter.com/dragonfly_oss)
- **DingTalk**: [22880028764](https://qr.dingtalk.com/action/joingroup?code=v1,k1,pkV9IbsSyDusFQdByPSK3HfCG61ZCLeb8b/lpQ3uUqI=&_dt_no_comment=1&origin=11)
## Contributing

View File

@ -26,6 +26,27 @@ import (
type FileSizeLevel string
func (f FileSizeLevel) String() string {
switch f {
case FileSizeLevelNano:
return "Nano(1B)"
case FileSizeLevelMicro:
return "Micro(1KB)"
case FileSizeLevelSmall:
return "Small(1MB)"
case FileSizeLevelMedium:
return "Medium(10MB)"
case FileSizeLevelLarge:
return "Large(1GB)"
case FileSizeLevelXLarge:
return "XLarge(10GB)"
case FileSizeLevelXXLarge:
return "XXLarge(30GB)"
default:
return "Unknow"
}
}
const (
FileSizeLevelNano FileSizeLevel = "nano"
FileSizeLevelMicro FileSizeLevel = "micro"
@ -36,6 +57,16 @@ const (
FileSizeLevelXXLarge FileSizeLevel = "xxlarge"
)
var FileSizeLevels = []FileSizeLevel{
FileSizeLevelNano,
FileSizeLevelMicro,
FileSizeLevelSmall,
FileSizeLevelMedium,
FileSizeLevelLarge,
FileSizeLevelXLarge,
FileSizeLevelXXLarge,
}
type FileServer interface {
GetFileURL(FileSizeLevel, string) (*url.URL, error)
}

View File

@ -125,6 +125,7 @@ func printTable(downloads map[backend.FileSizeLevel][]*Download) {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"File Size Level", "Times", "Min Cost", "Max Cost", "Avg Cost"})
rows := map[backend.FileSizeLevel][]string{}
for fileSizeLevel, records := range downloads {
var minCost, maxCost, totalCost time.Duration
if len(records) > 0 {
@ -145,13 +146,20 @@ func printTable(downloads map[backend.FileSizeLevel][]*Download) {
}
avgCost := totalCost / time.Duration(len(records))
table.Append([]string{
fmt.Sprintf("%s", fileSizeLevel),
rows[fileSizeLevel] = []string{
fileSizeLevel.String(),
fmt.Sprintf("%d", len(records)),
formatDuration(minCost),
formatDuration(maxCost),
formatDuration(avgCost),
})
}
}
for _, fileSizeLevel := range backend.FileSizeLevels {
if row, ok := rows[fileSizeLevel]; ok {
table.Append(row)
continue
}
}
table.SetAlignment(tablewriter.ALIGN_LEFT)