-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
674 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Benchmark TiDB | ||
|
||
## Table Of Contents | ||
|
||
- [Prerequisites](#prerequisites) | ||
- [Sysbench](#sysbench) | ||
* [Customize with kustomize](#customize-with-kustomize) | ||
+ [More customizations](#more-customizations) | ||
* [Prepare: Create test tables and insert test records](#prepare-create-test-tables-and-insert-test-records) | ||
* [Warmup TiDB](#warmup-tidb) | ||
* [Run benchmark](#run-benchmark) | ||
|
||
## Prerequisites | ||
|
||
You must run a TiDB cluster in your Kubernetes environment first. You can follow our | ||
docs [here](https://pingcap.com/docs/v3.0/tidb-in-kubernetes/deploy/prerequisites/). | ||
|
||
Please note that it's recommended to prepare a dedicated node to run your | ||
benchmark tool, e.g. sysbench. | ||
|
||
We also require [kustomize] to customize our manifest yaml files. You can | ||
follow | ||
[this](https://github.com/kubernetes-sigs/kustomize/blob/master/docs/INSTALL.md) | ||
to install latest kustomize on your machine. | ||
|
||
## Sysbench | ||
|
||
### Customize with kustomize | ||
|
||
We assume you are working in the root of tidb-operator repo. If you don't have | ||
a copy, you can run `git clone --depth=1 https://github.com/pingcap/tidb-operator` | ||
to clone it onto your local machine. | ||
|
||
Configure environments: | ||
|
||
``` | ||
TIDB_HOST="<your-tidb-host>" # this can be tidb service name, pod ip or load balancer ip, etc. | ||
``` | ||
|
||
Create `kustomization.yaml`: | ||
|
||
``` | ||
mkdir -p sysbench/output | ||
cat <<EOF > sysbench/kustomization.yaml | ||
resources: | ||
- ../manifests/sysbench | ||
commonAnnotations: | ||
tidb-host: $TIDB_HOST | ||
EOF | ||
``` | ||
|
||
Optionally, if you want to change tidb user, port, password or other | ||
configurations you can customize them in `commonAnnotations` or `patches` | ||
fields: | ||
|
||
``` | ||
commonAnnotations: | ||
tidb-password: "root" | ||
patches: | ||
- patch: |- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: sysbench-bench | ||
spec: | ||
template: | ||
metadata: | ||
annotations: | ||
sysbench-threads: "100" | ||
sysbench-test-name: oltp_read_write | ||
``` | ||
|
||
Label the node to run sysbench: | ||
|
||
``` | ||
kubectl label nodes <sysbench-node> dedicated=sysbench | ||
``` | ||
|
||
Run `kustomize`: | ||
|
||
``` | ||
kustomize build sysbench/ -o sysbench/output/ | ||
``` | ||
|
||
#### More customizations | ||
|
||
Change sysbench image, here is an example: | ||
|
||
``` | ||
patches: | ||
- patch: |- | ||
- op: replace | ||
path: /spec/template/spec/containers/0/image | ||
value: your-sysbench-image | ||
target: | ||
kind: Job | ||
``` | ||
|
||
### Prepare: Create test tables and insert test records | ||
|
||
``` | ||
kubectl apply -f sysbench/output/*config.yaml | ||
kubectl apply -f sysbench/output/*prepare.yaml | ||
``` | ||
|
||
You can run `kubectl logs -l job-name=sysbench-prepare` to view logs. | ||
|
||
### Warmup TiDB | ||
|
||
``` | ||
kubectl apply -f sysbench/output/*warmup.yaml | ||
``` | ||
|
||
You can run `kubectl logs -l job-name=sysbench-warmup` to view logs. | ||
|
||
### Run benchmark | ||
|
||
``` | ||
kubectl apply -f sysbench/output/*bench.yaml | ||
``` | ||
|
||
You can run `kubectl logs -l job-name=sysbench-bench` to view logs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: sysbench-bench | ||
labels: | ||
app: sysbench-bench | ||
spec: | ||
parallelism: 3 | ||
template: | ||
metadata: | ||
labels: | ||
app: sysbench-bench | ||
spec: | ||
restartPolicy: Never | ||
containers: | ||
- name: sysbench | ||
image: uhub.ucloud.cn/pingcap/sysbench:latest | ||
env: | ||
env: | ||
- name: TABLE_COUNT | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.annotations['table-count'] | ||
- name: TABLE_SIZE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.annotations['table-size'] | ||
- name: TIDB_HOST | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.annotations['tidb-host'] | ||
- name: TIDB_PORT | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.annotations['tidb-port'] | ||
- name: TIDB_USER | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.annotations['tidb-user'] | ||
- name: TIDB_PASSWORD | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.annotations['tidb-password'] | ||
- name: TIDB_DB | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.annotations['tidb-db'] | ||
- name: SYSBENCH_TIME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.annotations['sysbench-time'] | ||
- name: SYSBENCH_THREADS | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.annotations['sysbench-threads'] | ||
- name: SYSBENCH_TEST_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.annotations['sysbench-test-name'] | ||
command: | ||
- sysbench | ||
- --config-file=/etc/sysbench/common.conf | ||
- --mysql-host=$(TIDB_HOST) | ||
- --mysql-port=$(TIDB_PORT) | ||
- --mysql-user=$(TIDB_USER) | ||
- --mysql-password=$(TIDB_PASSWORD) | ||
- --mysql-db=$(TIDB_DB) | ||
- --tables=$(TABLE_COUNT) | ||
- --table-size=$(TABLE_SIZE) | ||
- --time=$(SYSBENCH_TIME) | ||
- --threads=$(SYSBENCH_THREADS) | ||
- $(SYSBENCH_TEST_NAME) | ||
- run | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/sysbench | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: sysbench-config | ||
items: | ||
- key: common | ||
path: common.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: sysbench-config | ||
data: | ||
common: | | ||
db-driver=mysql | ||
rand-type=uniform | ||
rand-seed=0 | ||
report-interval=10 |
Oops, something went wrong.