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 wrkTo make the benchmark.sh script executable, use the following command:
chmod +x benchmark.shTo run the benchmark script, execute:
./benchmark.shRun the server by the following command:
go run main.goThe benchmark.sh script performs the following actions:
-
Generate Random Numbers:
- Creates
100,000random numbers and saves them intoinserts.jsonfor insert operations andfinds.txtfor find operations.
- Creates
-
Insert Numbers into Server:
- Reads the
inserts.jsonfile and usescurlto send POST requests to insert each number into the server athttp://localhost:8080/v2/numbers/{index}/{value}.
- Reads the
-
Create Lua Script for
wrkPOST Requests:- Generates a
post.luascript to simulate random insert operations usingwrk.
- Generates a
-
Benchmark Insert Operation:
- Uses
wrkto benchmark the insert operation with 12 threads, 100 connections, for 30 seconds.
- Uses
-
Create Lua Script for
wrkGET Requests:- Generates a
get.luascript to simulate find operations using values fromfinds.txt.
- Generates a
-
Benchmark Find Operation:
- Uses
wrkto 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