This guide provides instructions on how to use the provided benchmark bash script with wrk
.
The benchmark.sh
script generates random numbers, inserts them into server, and benchmarks the insert
and find
operations.
Ensure you have the following installed on your system:
wrk
: HTTP benchmarking toolcurl
: Command-line tool for transferring data with URLs
To install wrk on a Linux system, use the following command:
sudo apt-get install wrk
To make the benchmark.sh
script executable, use the following command:
chmod +x benchmark.sh
To run the benchmark script, execute:
./benchmark.sh
Run the server by the following command:
go run main.go
The benchmark.sh
script performs the following actions:
-
Generate Random Numbers:
- Creates
100,000
random numbers and saves them intoinserts.json
for insert operations andfinds.txt
for find operations.
- Creates
-
Insert Numbers into Server:
- Reads the
inserts.json
file and usescurl
to send POST requests to insert each number into the server athttp://localhost:8080/v2/numbers/{index}/{value}
.
- Reads the
-
Create Lua Script for
wrk
POST Requests:- Generates a
post.lua
script to simulate random insert operations usingwrk
.
- Generates a
-
Benchmark Insert Operation:
- Uses
wrk
to benchmark the insert operation with 12 threads, 100 connections, for 30 seconds.
- Uses
-
Create Lua Script for
wrk
GET Requests:- Generates a
get.lua
script to simulate find operations using values fromfinds.txt
.
- Generates a
-
Benchmark Find Operation:
- Uses
wrk
to benchmark the find operation with 12 threads, 100 connections, for 30 seconds.
- Uses
-
Cleanup:
- Removes the generated files
inserts.json
,finds.txt
,post.lua
, andget.lua
.
- Removes the generated files