Skip to content

Commit 423c03e

Browse files
authored
Update benchmarking.md
1 parent afe65fd commit 423c03e

1 file changed

Lines changed: 34 additions & 30 deletions

File tree

  • content/learning-paths/servers-and-cloud-computing/mysql-azure

content/learning-paths/servers-and-cloud-computing/mysql-azure/benchmarking.md

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,32 @@ layout: learningpathall
88

99
## Benchmark MySQL on Azure Cobalt 100 Arm-based instances and x86_64 instances
1010

11-
`mysqlslap` is the official MySQL benchmarking tool used to simulate multiple client connections and measure query performance. It helps evaluate **read/write throughput, query response times**, and overall MySQL server performance under different workloads, making it ideal for baseline testing and optimization.
11+
To understand how MySQL performs on Azure Cobalt 100 (Arm64) VMs compared to x86_64 instances, you can use the built-in mysqlslap tool.
12+
13+
`mysqlslap` is the official MySQL benchmarking tool used to simulate multiple client connections and measure query performance. It helps evaluate read/write throughput, query response times, and overall MySQL server performance under different workloads, making it ideal for baseline testing and optimization.
1214

1315
## Steps for MySQL Benchmarking with mysqlslap
1416

1517
1. Connect to MySQL and Create a Database
1618

17-
To access the MySQL server, use the following command based on your `admin` user password:
19+
Before running `mysqlslap`, you will create a dedicated test database so that benchmarking doesn’t interfere with your application data. This ensures clean test results and avoids accidental modifications to production schemas.
20+
Connect to MySQL using the admin user:
1821

1922
```console
2023
mysql -u admin -p
2124
```
22-
Once logged in, you can create a benchmark_db using SQL commands like:
25+
Once logged in, create a benchmarking database:
2326

2427
```sql
2528
CREATE DATABASE benchmark_db;
2629
USE benchmark_db;
2730
```
2831

29-
3. Create a Table and Populate Data
32+
2. Create a Table and Populate Data
33+
34+
With a dedicated `benchmark_db` created, the next step is to define a test table and populate it with data. This simulates a realistic workload so that `mysqlslap` can measure query performance against non-trivial datasets.
3035

31-
After logging into MySQL, you can create a table to store benchmark data. Here’s a simple example:
36+
Create a benchmark table:
3237

3338
```sql
3439
CREATE TABLE benchmark_table (
@@ -37,14 +42,18 @@ CREATE TABLE benchmark_table (
3742
score INT
3843
);
3944
```
40-
Insert some sample rows manually:
45+
Insert Sample Rows Manually:
4146

47+
For quick validation:
4248
```sql
4349
INSERT INTO benchmark_table (username,score) VALUES
4450
('John',100),('Jane',200),('Mike',300);
4551
```
52+
This verifies that inserts work correctly and allows you to test small queries.
4653

47-
Or populate automatically with 1000 rows:
54+
Populate Automatically with 1000 Rows
55+
56+
For benchmarking, larger datasets give more meaningful results. You can use a stored procedure to generate rows programmatically:
4857

4958
```sql
5059
DELIMITER //
@@ -62,15 +71,14 @@ DELIMITER ;
6271
CALL populate_benchmark_data();
6372
DROP PROCEDURE populate_benchmark_data;
6473
```
65-
- The table `benchmark_table` has three columns: `record_id` (primary key), `username`, and `score`.
66-
- You can insert a few rows manually for testing or use a procedure to generate **1000 rows automatically** for more realistic benchmarking
74+
At this stage, you have a populated `benchmark_table` inside `benchmark_db`. This provides a realistic dataset for running `mysqlslap`, enabling you to measure how MySQL performs on Azure Cobalt 100 under read-heavy, write-heavy, or mixed workloads.
6775

6876
## Run a Simple Read/Write Benchmark
6977

70-
Once your table is ready, you can use `mysqlslap` to simulate multiple clients performing queries. This helps test MySQL’s performance under load.
78+
With the `benchmark_table` populated, you can run a synthetic workload using mysqlslap to simulate multiple clients performing inserts or queries at the same time. This tests how well MySQL handles concurrent connections and query execution.
7179

7280
```console
73-
mysqlslap --user=admin --password="MyStrongPassword!" --host=127.0.0.1 --concurrency=10 --iterations=5 --query="INSERT INTO benchmark_db.benchmark_table (username,score) VALUES('TestUser',123);" --create-schema=benchmark_db
81+
mysqlslap --user=admin --password=`MyStrongPassword!` --host=127.0.0.1 --concurrency=10 --iterations=5 --query="INSERT INTO benchmark_db.benchmark_table (username,score) VALUES('TestUser',123);" --create-schema=benchmark_db
7482
```
7583
- **--user / --password:** MySQL login credentials.
7684
- **--host:** MySQL server address (127.0.0.1 for local).
@@ -79,7 +87,7 @@ mysqlslap --user=admin --password="MyStrongPassword!" --host=127.0.0.1 -
7987
- **--query:** The SQL statement to run repeatedly.
8088
- **--create-schema:** The database in which to run the query.
8189

82-
You should see output similar to the following:
90+
You should see output similar to:
8391

8492
```output
8593
Benchmark
@@ -90,13 +98,15 @@ Benchmark
9098
Average number of queries per client: 1
9199
```
92100

93-
Below command runs a **read benchmark** on your MySQL database using `mysqlslap`. It simulates multiple clients querying the table at the same time and records the results.
101+
Run a Read Benchmark (table scan):
102+
103+
You can now run a test that simulates multiple clients querying the table at the same time and records the results:
94104

95105
```console
96106
mysqlslap --user=admin --password="MyStrongPassword!" --host=127.0.0.1 --concurrency=10 --iterations=5 --query="SELECT * FROM benchmark_db.benchmark_table WHERE record_id < 500;" --create-schema=benchmark_db --verbose | tee -a /tmp/mysqlslap_benchmark.log
97107
```
98108

99-
You should see output similar to the following:
109+
You should see output similar to:
100110

101111
```output
102112
Benchmark
@@ -109,11 +119,11 @@ Benchmark
109119

110120
## Benchmark Results Table Explained:
111121

112-
- **Average number of seconds to run all queries:** This is the average time it took for all the queries in one iteration to complete across all clients. It gives you a quick sense of overall performance.
113-
- **Minimum number of seconds to run all queries:** This is the fastest time any iteration of queries took.
114-
- **Maximum number of seconds to run all queries:** This is the slowest time any iteration of queries took. The closer this is to the average, the more consistent your performance is.
115-
- **Number of clients running queries:** Indicates how many simulated users (or connections) ran queries simultaneously during the test.
116-
- **Average number of queries per client:** Shows the average number of queries each client executed in the benchmark iteration.
122+
Average number of seconds to run all queries: This is the average time it took for all the queries in one iteration to complete across all clients. It gives you a quick sense of overall performance.
123+
Minimum number of seconds to run all queries: This is the fastest time any iteration of queries took.
124+
Maximum number of seconds to run all queries: This is the slowest time any iteration of queries took. The closer this is to the average, the more consistent your performance is.
125+
Number of clients running queries: Indicates how many simulated users (or connections) ran queries simultaneously during the test.
126+
Average number of queries per client: Shows the average number of queries each client executed in the benchmark iteration.
117127

118128
## Benchmark summary on Arm64:
119129
Here is a summary of benchmark results collected on an Arm64 **D4ps_v6 Ubuntu Pro 24.04 LTS virtual machine**.
@@ -123,21 +133,15 @@ Here is a summary of benchmark results collected on an Arm64 **D4ps_v6 Ubuntu Pr
123133
| INSERT | 0.267 | 0.265 | 0.271 | 10 | 1 |
124134
| SELECT | 0.263 | 0.261 | 0.264 | 10 | 1 |
125135

126-
## Benchmark summary on x86_64:
127-
Here is a summary of the benchmark results collected on x86_64 **D4s_v6 Ubuntu Pro 24.04 LTS virtual machine**.
128-
129-
| Query Type | Average Time (s) | Minimum Time (s) | Maximum Time (s) | Clients | Avg Queries per Client |
130-
|------------|-----------------|-----------------|-----------------|--------|----------------------|
131-
| INSERT | 0.243 | 0.231 | 0.273 | 10 | 1 |
132-
| SELECT | 0.222 | 0.214 | 0.233 | 10 | 1 |
133136

134137
## Insights from Benchmark Results
135138

136139
The benchmark results on the Arm64 virtual machine show:
137140

138-
- **Balanced Performance for Read and Write Queries:** Both `INSERT` and `SELECT` queries performed consistently, with average times of **0.267s** and **0.263s**, respectively.
139-
- **Low Variability Across Iterations:** The difference between the minimum and maximum times was very small for both query types, indicating stable and predictable behavior under load.
140-
- **Moderate Workload Handling:** With **10 clients** and an average of **1 query per client**, the system handled concurrent operations efficiently without significant delays.
141-
- **Key Takeaway:** The MySQL setup on Arm64 provides reliable and steady performance for both data insertion and retrieval tasks, making it a solid choice for applications requiring dependable database operations.
141+
Balanced Performance for Read and Write Queries: Both `INSERT` and `SELECT` queries performed consistently, with average times of 0.267s and 0.263s, respectively.
142+
Low Variability Across Iterations: The difference between the minimum and maximum times was very small for both query types, indicating stable and predictable behavior under load.
143+
Moderate Workload Handling: With 10 clients and an average of 1 query per client, the system handled concurrent operations efficiently without significant delays.
144+
145+
This demonstrates that the MySQL setup on Arm64 provides reliable and steady performance for both data insertion and retrieval tasks, making it a solid choice for applications requiring dependable database operations.
142146

143147
You have now benchmarked MySql on an Azure Cobalt 100 Arm64 virtual machine and compared results with x86_64.

0 commit comments

Comments
 (0)