|
| 1 | +# Performance Optimization Guidance |
| 2 | + |
| 3 | +> This is a reference benchmark process document designed to |
| 4 | +> assist in performance analysis and optimization for **client**. |
| 5 | +> This document provides as general a testing framework as possible, |
| 6 | +> allowing developers with needs to adjust it |
| 7 | +> according to their specific circumstances across various platform. |
| 8 | +
|
| 9 | +## Flow |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## Preparation |
| 14 | + |
| 15 | +### 1. Set up Dragonfly cluster |
| 16 | + |
| 17 | +- Please refer to [official doc](https://d7y.io/docs/next/getting-started/installation/helm-charts/). |
| 18 | + |
| 19 | +### 2. Start a file server |
| 20 | + |
| 21 | +- start with docker: |
| 22 | + |
| 23 | +```bash |
| 24 | +export FILE_SERVER_PORT=12345 |
| 25 | +docker run -d --rm -p ${FILE_SERVER_PORT}:80 --name dragonfly-fs dragonflyoss/file-server:latest |
| 26 | +``` |
| 27 | + |
| 28 | +- check |
| 29 | + |
| 30 | +```bash |
| 31 | +# return success if ready |
| 32 | +curl -s -o /dev/null \ |
| 33 | + -w "%{http_code}" \ |
| 34 | + http://localhost:12345/nano \ |
| 35 | +| grep -q "200" \ |
| 36 | +&& echo "Success" \ |
| 37 | +|| echo "Failed" |
| 38 | +``` |
| 39 | + |
| 40 | +- optional: |
| 41 | + |
| 42 | +> you can build your own image, take a reference from [**Dockerfile**](https://github.com/dragonflyoss/perf-tests/blob/main/tools/file-server/Dockerfile). |
| 43 | +
|
| 44 | +### 3. Prepare related tools |
| 45 | + |
| 46 | +- Request Generator: [**oha**](https://github.com/hatoo/oha) |
| 47 | + |
| 48 | +```bash |
| 49 | +brew install oha |
| 50 | +``` |
| 51 | + |
| 52 | +- Profiling: [**flamegraph**](https://github.com/flamegraph-rs/flamegraph) |
| 53 | + |
| 54 | +```bash |
| 55 | +cargo install flamegraph |
| 56 | +``` |
| 57 | + |
| 58 | +### 4. start the target client |
| 59 | + |
| 60 | +- compile the target binary |
| 61 | + |
| 62 | +```bash |
| 63 | +cargo build --release --bin dfdaemon |
| 64 | +``` |
| 65 | + |
| 66 | +- connect to dragonfly cluster |
| 67 | + |
| 68 | +```bash |
| 69 | +# prepare client.yaml by yourself. |
| 70 | +./target/release/dfdaemon --config client.yaml -l info --verbose |
| 71 | +``` |
| 72 | + |
| 73 | +## FlameGraph |
| 74 | + |
| 75 | +Now, let's start benchmark with the following params: |
| 76 | + |
| 77 | +- $FILE_SERVER_ADDRESS |
| 78 | +- $CLIENT_PROXY_ADDRESS |
| 79 | + |
| 80 | +### collect flamegraph |
| 81 | + |
| 82 | +- capture the flamegraph: |
| 83 | + |
| 84 | +```bash |
| 85 | +## stop after all requests done. |
| 86 | +sudo flamegraph -o my_flamegraph.svg --pid 3442 |
| 87 | +``` |
| 88 | + |
| 89 | +- make the request: |
| 90 | + |
| 91 | +```bash |
| 92 | +oha -c 1000 \ |
| 93 | + -n 100 \ |
| 94 | + --rand-regex-url $FILE_SERVER_ADDRESS/\(nano\|micro\|small\|medium\|large\) \ |
| 95 | + -x $CLIENT_PROXY_ADDRESS |
| 96 | +``` |
0 commit comments