Skip to content

Commit d37551d

Browse files
Merge pull request #1244 from jsrz/mysql_tuning_update
Refreshed MySQL Tuning Learning Path
2 parents 0bed590 + 7a24aa0 commit d37551d

File tree

4 files changed

+70
-80
lines changed

4 files changed

+70
-80
lines changed

content/learning-paths/servers-and-cloud-computing/mysql_tune/_review.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@
1313
review:
1414
- questions:
1515
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?
1717
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"
2121
correct_answer: 2
2222
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.
2424
2525
- questions:
2626
question: >
2727
What is the recommended size for the MySQL buffer pool?
2828
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"
3232
correct_answer: 3
3333
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).
3535
3636
- questions:
3737
question: >

content/learning-paths/servers-and-cloud-computing/mysql_tune/before_and_after.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ layout: "learningpathall"
66

77
## About database performance tuning
88

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`.
1010

1111
## Importance of tuning
1212

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.

content/learning-paths/servers-and-cloud-computing/mysql_tune/kernel_comp_lib.md

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,52 @@
11
---
22
# User change
3-
title: "System, Kernel, compiler, and Libraries"
3+
title: "System, Kernel, Compiler, and Libraries"
44

55
weight: 3 # 1 is first, 2 is second, etc.
66

77
# Do not modify these elements
88
layout: "learningpathall"
99
---
1010

11-
## Storage technology and file system format
11+
## Storage technology, file system format, and disk scheduling
1212

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.
1414

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.
1618

1719
## MySQL storage engines
1820

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.
2022

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).
2224

2325
## Kernel configuration
2426

2527
`MySQL` can benefit from adjustments to kernel parameters. Below is a list of kernel related settings that can have a positive impact on performance.
2628

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-
5229
### Linux virtual memory subsystem
5330

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.
5532

5633
These settings can be changed in the `/etc/sysctl.conf` file, or by using the `sysctl` command.
5734

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).
6136

62-
To list all kernel parameters available:
37+
To list all sysctl parameters available:
6338

6439
```bash
6540
sudo sysctl -a
6641
```
6742

43+
See the `sysctl` command documentation for more.
44+
6845
### Huge memory pages
6946

7047
`MySQL` benefits from using huge memory pages. Huge pages reduce how often virtual memory pages are mapped to physical memory.
7148

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:
7350

7451
```bash
7552
cat /proc/meminfo | grep ^Huge
@@ -86,11 +63,11 @@ Hugepagesize: 2048 kB
8663
Hugetlb: 0 kB
8764
```
8865

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).
9067

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.
9269

93-
The kernel parameter that enables huge pages is shown below:
70+
The sysctl parameter that enables huge pages is shown below:
9471

9572
```output
9673
vm.nr_hugepages
@@ -114,11 +91,9 @@ sudo sh -c 'echo "vm.nr_hugepages=500" >> /etc/sysctl.conf'
11491

11592
### Selecting the number of huge pages to use
11693

117-
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.
12095

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).
12297

12398
## Compiler Considerations
12499

0 commit comments

Comments
 (0)