Skip to content

Commit 8e7f7b9

Browse files
Custom bench (#293)
1 parent e4c6796 commit 8e7f7b9

4 files changed

Lines changed: 62 additions & 3 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,6 @@ benchmark_results/
9898

9999
# For local query testing
100100
queries/**
101+
102+
bench/url_files/*
103+
!bench/url_files/example_custom_bench.txt
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
http://localhost:8080/catalog
2+
http://localhost:8080/table/datafusion/information_schema/tables
3+
http://localhost:8080/table/datafusion/information_schema/views
4+
http://localhost:8080/table/datafusion/information_schema/columns

docs/http_server.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,34 @@ Prometheus metrics are automatically published.
3838
[flightsql_server]
3939
server_metrics_port = "0.0.0.0:9000"
4040
```
41+
42+
## Benchmarking
43+
44+
Something useful that comes from having an HTTP server is that we can leverage an extensive ecosystem of the HTTP load generation tools to benchmark our performance.
45+
46+
To get started with benchmarking you will first want to install the necessary tools.
47+
48+
```sh
49+
# Installs `oha` which is a CLI for HTTP benchmarking
50+
just install-tools
51+
```
52+
53+
Then you will want to start the `dft` HTTP server in one terminal window.
54+
55+
```sh
56+
just serve-http
57+
```
58+
59+
Finally, you can run a simple benchmark to make sure all the flows are working.
60+
61+
```sh
62+
# Benchmarks running `SELECT 1`
63+
just bench-http-basic
64+
```
65+
66+
You can add your own benchmark files in the `bench/url_files` directory to cater the benchmarks to your needs. An example file is provided that you can use as reference.
67+
68+
```sh
69+
just bench-http-custom example_custom_bench.txt
70+
```
71+

justfile

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22
# We use shebang in places where multi line constructs are needed
33
# Ref: https://github.com/casey/just?tab=readme-ov-file#if-statements
44

5-
# Assumes you already have `cargo` installed
6-
install-deps:
5+
# Installs `dft` dev tools. Assumes you already have `cargo` installed
6+
install-tools:
77
cargo install oha
88

9+
# Starts a debug HTTP server
10+
serve-http:
11+
RUST_LOG=info cargo r --features=http -- serve-http
12+
13+
# Starts a debug FlightSQL server
14+
serve-flight-sql:
15+
RUST_LOG=info cargo r --features=flightsql -- serve-flight-sql
16+
917
# You should already have run `cargo r --features=http -- serve-http` in another shell
1018
bench-http-basic:
1119
#!/usr/bin/env sh
@@ -14,4 +22,17 @@ bench-http-basic:
1422
echo "HTTP server not running on http://localhost:8080"
1523
exit 1
1624
fi
17-
oha "http://localhost:8080" -m POST -d '{"query": "SELECT 1"}'
25+
oha "http://localhost:8080/sql" -m POST -d 'SELECT 1'
26+
27+
# Run a custom benchmark script
28+
bench-http-custom file:
29+
#!/usr/bin/env sh
30+
http_code=$(curl "http://localhost:8080/health-check" --silent -o /dev/null -w "%{http_code}")
31+
if [ "$http_code" -ne "200" ]; then
32+
echo "HTTP server not running on http://localhost:8080"
33+
exit 1
34+
fi
35+
custom_bench_path="bench/url_files/{{file}}"
36+
echo "Running bench on $custom_bench_path"
37+
echo ""
38+
oha --urls-from-file "$custom_bench_path"

0 commit comments

Comments
 (0)