You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/mysql-azure/benchmarking.md
+34-30Lines changed: 34 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,27 +8,32 @@ layout: learningpathall
8
8
9
9
## Benchmark MySQL on Azure Cobalt 100 Arm-based instances and x86_64 instances
10
10
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.
12
14
13
15
## Steps for MySQL Benchmarking with mysqlslap
14
16
15
17
1. Connect to MySQL and Create a Database
16
18
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:
18
21
19
22
```console
20
23
mysql -u admin -p
21
24
```
22
-
Once logged in, you can create a benchmark_db using SQL commands like:
25
+
Once logged in, create a benchmarking database:
23
26
24
27
```sql
25
28
CREATEDATABASEbenchmark_db;
26
29
USE benchmark_db;
27
30
```
28
31
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.
30
35
31
-
After logging into MySQL, you can create a table to store benchmark data. Here’s a simple example:
INSERT INTO benchmark_table (username,score) VALUES
44
50
('John',100),('Jane',200),('Mike',300);
45
51
```
52
+
This verifies that inserts work correctly and allows you to test small queries.
46
53
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:
48
57
49
58
```sql
50
59
DELIMITER //
@@ -62,15 +71,14 @@ DELIMITER ;
62
71
CALL populate_benchmark_data();
63
72
DROP PROCEDURE populate_benchmark_data;
64
73
```
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.
67
75
68
76
## Run a Simple Read/Write Benchmark
69
77
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.
-**--query:** The SQL statement to run repeatedly.
80
88
-**--create-schema:** The database in which to run the query.
81
89
82
-
You should see output similar to the following:
90
+
You should see output similar to:
83
91
84
92
```output
85
93
Benchmark
@@ -90,13 +98,15 @@ Benchmark
90
98
Average number of queries per client: 1
91
99
```
92
100
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:
94
104
95
105
```console
96
106
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
97
107
```
98
108
99
-
You should see output similar to the following:
109
+
You should see output similar to:
100
110
101
111
```output
102
112
Benchmark
@@ -109,11 +119,11 @@ Benchmark
109
119
110
120
## Benchmark Results Table Explained:
111
121
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.
117
127
118
128
## Benchmark summary on Arm64:
119
129
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
123
133
| INSERT | 0.267 | 0.265 | 0.271 | 10 | 1 |
124
134
| SELECT | 0.263 | 0.261 | 0.264 | 10 | 1 |
125
135
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 |
The benchmark results on the Arm64 virtual machine show:
137
140
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.
142
146
143
147
You have now benchmarked MySql on an Azure Cobalt 100 Arm64 virtual machine and compared results with x86_64.
0 commit comments