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
Newer version of MySQL have changed a lot of the defaults. We've also
learned a bit more about tuning MySQL recently. This change refreshes
the learnings/suggestions we have for people running MySQL on Arm.
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/mysql_tune/_review.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,25 +13,25 @@
13
13
review:
14
14
- questions:
15
15
question: >
16
-
When tuning a thread count configuration parameter like innodb_read_io_threads or innodb_write_io_threads. What can often be a good starting value?
16
+
How do you select the number of huge pages that should be used?
17
17
answers:
18
-
- "One"
19
-
- "Total number of CPUs on the system"
20
-
- "Half the number of CPUs on the system"
18
+
- "Set to the size of the redo log file"
19
+
- "Divide the buffer pool size by the huge page size"
20
+
- "Set to the buffer pool size"
21
21
correct_answer: 2
22
22
explanation: >
23
-
The total number of CPUs is a good starting point because it can ensure you are using all compute resources on the system.
23
+
We divide by the bugger pool size because we want as much huge page space as there is buffer pool space.
24
24
25
25
- questions:
26
26
question: >
27
27
What is the recommended size for the MySQL buffer pool?
28
28
answers:
29
-
- "Up to 40% of system memory"
30
-
- "Up to 20% of system memory"
31
-
- "Up to 80% of system memory"
29
+
- "Up to 30-40% of system memory"
30
+
- "Up to 10-20% of system memory"
31
+
- "Up to 70-80% of system memory"
32
32
correct_answer: 3
33
33
explanation: >
34
-
The MySQL documentation suggests up to 80% of system memory. Depending on the use case, it's also possible that a much smaller percentage performs just as well as 80%.
34
+
The MySQL documentation suggests up to 80% of system memory. Depending on the use case, it's also possible that a much smaller percentage performs just as well as 80%. Buffer pool size is also automatically set to 75% of system memory if you use the innodb_dedicated_server option (See MySQL docs).
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/mysql_tune/before_and_after.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,12 @@ layout: "learningpathall"
6
6
7
7
## About database performance tuning
8
8
9
-
Deployment configurations and the profile of SQL requests made by clients will differ based on your use case. This means there is no one size fits all set of tuning parameters for `MySQL`. Use the information in this learning path to help you tune`MySQL` for your use case.
9
+
The configuration of a database and the types of requests made by clients to it will differ from use case to use case. This means there is no one size fits all set of tuning parameters for `MySQL`. Use the information in this learning path as general guidance to help with tuning`MySQL`.
10
10
11
11
## Importance of tuning
12
12
13
-
Application tuning allows you to gain performance without scaling your deployment up (bigger machines) or out (more machines). You have the option to use the gained performance or trade it for cost savings by reducing the total compute resources provisioned. Requirements vary based on the use case.
13
+
Application tuning allows you to gain performance without scaling a deployment up (bigger machines) or out (more machines). This gives the option to use the gained performance, or to trade it for cost savings by reducing the total compute resources provisioned.
14
+
15
+
## Note on MySQL Documentation
16
+
17
+
All links to [MySQL documentation](https://dev.mysql.com/doc/refman/en/) in this learning path point to the latest version of the documentation. If you are using an older version of MySQL, be sure to change the documentation version after clicking the links.
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/mysql_tune/kernel_comp_lib.md
+19-44Lines changed: 19 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,75 +1,52 @@
1
1
---
2
2
# User change
3
-
title: "System, Kernel, compiler, and Libraries"
3
+
title: "System, Kernel, Compiler, and Libraries"
4
4
5
5
weight: 3# 1 is first, 2 is second, etc.
6
6
7
7
# Do not modify these elements
8
8
layout: "learningpathall"
9
9
---
10
10
11
-
## Storage technology and file system format
11
+
## Storage technology, file system format, and disk scheduling
12
12
13
-
The underlying storage technology and the file system format can impact performance significantly. In general, locally attached SSD storage will perform best. However, network based storage systems can perform well. As always, performance is dependent on the request profile coming from clients. You should spend some time studying and experimenting with different storage technologies and configuration options.
13
+
The underlying storage technology and the file system format can impact performance. In general, locally attached SSD storage will perform best. However, network based storage systems can perform well. You should spend some time studying and experimenting with different storage technologies and configuration options.
14
14
15
-
Aside from the storage technology, the file system format used with `MySQL` can impact performance. The `xfs` file system is a good starting point. The `ext4` file system is another good alternative.
15
+
Aside from the storage technology, the file system format used with `MySQL` can impact performance. The `xfs` file system is a good starting point. The `ext4` file system is another good alternative. Last, it is recommended to use storage drives that are dedicated to the database (i.e. not shared with the OS or other applications).
16
+
17
+
When running in the cloud, the disk scheduling algorithm is typically set to `noop` or a similar "dumb" algorithm. This is typically optimal for `MySQL` in the cloud, so no adjustment is needed. However, if running `MySQL` on an on-prem server, it's a good idea to double check what the disk scheduling algorithm is, and possibly change it. According to the [Optimizing InnoDB Disk I/O documentation]https://dev.mysql.com/doc/refman/en/optimizing-innodb-diskio.html), `noop` or `deadline` might be better options. It's worth testing this with on-prem systems.
16
18
17
19
## MySQL storage engines
18
20
19
-
There are different storage engines available for `MySQL`. The default storage engine is `InnoDB`. `InnoDB` is good for performance testing and tuning.
21
+
There are different storage engines available for `MySQL`. The default storage engine is `InnoDB`. `InnoDB` is the default storage engine because it performs the best in the broadest set of use cases.
20
22
21
-
Information on alternative storage engines can be found in the [MySQL documentation](https://dev.mysql.com/doc/refman/8.0/en/storage-engines.html).
23
+
Information on alternative storage engines can be found in the [MySQL documentation](https://dev.mysql.com/doc/refman/en/storage-engines.html).
22
24
23
25
## Kernel configuration
24
26
25
27
`MySQL` can benefit from adjustments to kernel parameters. Below is a list of kernel related settings that can have a positive impact on performance.
26
28
27
-
### Linux-PAM limits
28
-
29
-
Linux-PAM limits can be changed in the `/etc/security/limits.conf` file, or by using the `ulimit` command.
30
-
31
-
If you want more information about how to display and modify parameters check the documentation of the `ulimit` command.
32
-
33
-
To display all limits:
34
-
```bash
35
-
ulimit -a
36
-
```
37
-
38
-
To display the `memlock` (Max locked-in-memory address space) limit only:
39
-
```bash
40
-
ulimit -l
41
-
```
42
-
43
-
`memlock` is the only PAM limit which is useful to adjust for `MySQL`.
44
-
45
-
The suggested value for `memlock` is `unlimited` when using huge pages with `MySQL`.
46
-
47
-
Enabling huge pages can result in significant performance gains (discussed below).
48
-
49
-
The suggestion to set `memlock` when huge pages are enabled can be found in the [MySQL documentation](https://dev.mysql.com/doc/refman/8.1/en/large-page-support.html).
50
-
51
-
52
29
### Linux virtual memory subsystem
53
30
54
-
Making changes to the Linux Virtual Memory subsystem can also improve performance.
31
+
Making changes to the Linux Virtual Memory subsystem can improve performance.
55
32
56
33
These settings can be changed in the `/etc/sysctl.conf` file, or by using the `sysctl` command.
57
34
58
-
If you want more information about how to display and modify virtual memory parameters check the documentation of the `sysctl` command.
59
-
60
-
Documentation on each of these parameters can be found in the [admin-guide for sysctl in the Linux source code](https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/sysctl/vm.rst).
35
+
Documentation on the virtual memory subsystem parameters can be found in the [admin-guide for sysctl in the Linux source code](https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/sysctl/vm.rst).
61
36
62
-
To list all kernel parameters available:
37
+
To list all sysctl parameters available:
63
38
64
39
```bash
65
40
sudo sysctl -a
66
41
```
67
42
43
+
See the `sysctl` command documentation for more.
44
+
68
45
### Huge memory pages
69
46
70
47
`MySQL` benefits from using huge memory pages. Huge pages reduce how often virtual memory pages are mapped to physical memory.
71
48
72
-
To see the current memory page configuration, run the following command on the host:
49
+
To see the current huge memory page configuration, run the following command on the host:
73
50
74
51
```bash
75
52
cat /proc/meminfo | grep ^Huge
@@ -86,11 +63,11 @@ Hugepagesize: 2048 kB
86
63
Hugetlb: 0 kB
87
64
```
88
65
89
-
Huge pages are not being used if `HugePages_Total` is 0 (this is the default).
66
+
Huge pages are not being used if `HugePages_Total` is 0 (this is typically the default).
90
67
91
-
Also note that `Hugepagesize` is 2MB which is the typical default for huge pages on Linux.
68
+
Also note that `Hugepagesize` is 2MiB which is the typical default for huge pages on Linux.
92
69
93
-
The kernel parameter that enables huge pages is shown below:
70
+
The sysctl parameter that enables huge pages is shown below:
You should set `vm.nr_hugepages` to a value that gives a total huge page space slightly larger than the `MySQL` buffer pool size (discussed later).
118
-
119
-
It should be slightly larger than the buffer pool because `MySQL` will use additional memory for things like connection management.
94
+
You should set `vm.nr_hugepages` to a value that gives a total huge page space equal to or slightly larger than the `MySQL` buffer pool size. Selecting the buffer pool size is discussed in the [Tuning MySQL](/learning-paths/servers-and-cloud-computing/mysql_tune/tuning) section.
120
95
121
-
More information on the different parameters that affect the configuration of huge pages can be found in the [admin-guide for hugetlbpage in the Linux source code](https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/mm/hugetlbpage.rst).
96
+
Typically, only the number of huge pages needs to be configured. However, for more information on the different parameters that affect the configuration of huge pages, review the [admin-guide for hugetlbpage in the Linux source code](https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/mm/hugetlbpage.rst).
0 commit comments