Skip to content

Commit 720eb26

Browse files
committed
ZOOKEEPER-3823: Add a benchmark tool for testing watch feature performance
1 parent 66c4efe commit 720eb26

4 files changed

Lines changed: 579 additions & 0 deletions

File tree

‎bin/zkWatchBenchmark.cmd‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@echo off
2+
REM Licensed to the Apache Software Foundation (ASF) under one or more
3+
REM contributor license agreements. See the NOTICE file distributed with
4+
REM this work for additional information regarding copyright ownership.
5+
REM The ASF licenses this file to You under the Apache License, Version 2.0
6+
REM (the "License"); you may not use this file except in compliance with
7+
REM the License. You may obtain a copy of the License at
8+
REM
9+
REM http://www.apache.org/licenses/LICENSE-2.0
10+
REM
11+
REM Unless required by applicable law or agreed to in writing, software
12+
REM distributed under the License is distributed on an "AS IS" BASIS,
13+
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
REM See the License for the specific language governing permissions and
15+
REM limitations under the License.
16+
17+
setlocal
18+
call "%~dp0zkEnv.cmd"
19+
20+
set ZOOMAIN=org.apache.zookeeper.server.watch.WatchBenchmarkTool
21+
call %JAVA% -cp "%CLASSPATH%" %ZOOMAIN% %*
22+
23+
endlocal
24+

‎bin/zkWatchBenchmark.sh‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
#
19+
# If this scripted is run out of /usr/bin or some other system bin directory
20+
# it should be linked to and not copied. Things like java jar files are found
21+
# relative to the canonical path of this script.
22+
#
23+
24+
# use POSIX interface, symlink is followed automatically
25+
ZOOBIN="${BASH_SOURCE-$0}"
26+
ZOOBIN="$(dirname "${ZOOBIN}")"
27+
ZOOBINDIR="$(cd "${ZOOBIN}"; pwd)"
28+
29+
if [ -e "$ZOOBIN/../libexec/zkEnv.sh" ]; then
30+
. "$ZOOBINDIR"/../libexec/zkEnv.sh
31+
else
32+
. "$ZOOBINDIR"/zkEnv.sh
33+
fi
34+
35+
"$JAVA" -cp "$CLASSPATH" $JVMFLAGS \
36+
org.apache.zookeeper.server.watch.WatchBenchmarkTool "$@"
37+
38+

‎zookeeper-docs/src/main/resources/markdown/zookeeperTools.md‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ limitations under the License.
2929
* [Benchmark](#Benchmark)
3030
* [YCSB](#YCSB)
3131
* [zk-smoketest](#zk-smoketest)
32+
* [zkWatchBenchmark](#zkWatchBenchmark)
3233

3334
* [Testing](#Testing)
3435
* [Fault Injection Framework](#fault-injection)
@@ -560,6 +561,43 @@ Run the workload test:
560561
**zk-smoketest** provides a simple smoketest client for a ZooKeeper ensemble. Useful for verifying new, updated,
561562
existing installations. More details are [here](https://github.com/phunt/zk-smoketest).
562563
564+
<a name="zkWatchBenchmark"></a>
565+
566+
### zkWatchBenchmark
567+
- A benchmark tool that benchmarks the watch throughput and latency, which supports multiple clients threads
568+
- See **ZOOKEEPER-3823** for the design document
569+
- Usages:
570+
571+
```
572+
# command help
573+
./zkWatchBenchmark.sh -help
574+
575+
# a quick start
576+
./zkWatchBenchmark.sh -root_path /bench-watch -connect_string 127.0.0.1:2181
577+
578+
# full parameters
579+
./zkWatchBenchmark.sh -root_path /bench-watch -threads 100 -znode_count 1000 -connect_string \n
580+
192.168.10.43:2181,192.168.10.45:2181,192.168.10.47:2181 \n
581+
-client_configuration /tmp/zk-conf.txt -timeout 300000
582+
583+
Notification expected count: 200000, received count: 200000 (1.0000), loss count: 0 (0.0000)
584+
avg watch notify latency = 67.6451 ms
585+
min watch notify latency = 0 ms
586+
max watch notify latency = 273 ms
587+
cnt watch notify latency = 200000
588+
sum watch notify latency = 13529023 ms
589+
p50 watch notify latency = 38 ms
590+
p95 watch notify latency = 179 ms
591+
p99 watch notify latency = 208 ms
592+
p999 watch notify latency = 267 ms
593+
Total time: 7587 ms, watch benchmark total time: 1389 ms, throughput: 143988.48 op/s
594+
```
595+
596+
- Notes:
597+
```
598+
`export JVMFLAGS="-Xms12g -Xmx12g"` to have more JVM heap size to avoid `GC overhead limit exceeded` when you have a large scale testing
599+
`-v` to print a detailed logs when you find no benchmark output result for a long time
600+
```
563601
564602
<a name="Testing"></a>
565603

0 commit comments

Comments
 (0)