启用 innodb_dedicated_server 对性能有好处吗?
Is enabling innodb_dedicated_server good for performance?
来自 MySQL8 文档:
When innodb_dedicated_server is enabled, InnoDB automatically configures the following variables:
innodb_buffer_pool_size
innodb_log_file_size
innodb_log_files_in_group (as of MySQL 8.0.14)
innodb_flush_method
Only consider enabling innodb_dedicated_server if the MySQL instance resides on a dedicated server
where it can use all available system resources. Enabling innodb_dedicated_server is not recommended
if the MySQL instance shares system resources with other applications.
假设服务器专用于 MySQL,启用 innodb_dedicated_server 是否真的比我自己调整这些参数提供更好的性能?
刚刚调整。
为所有内容提供“良好”的默认值是一项具有挑战性的任务。最大的障碍是不知道同一台服务器上的其他产品(Java、WordPress 等)运行 会消耗多少机器内存和 CPU。
大量MySQL服务器被大玩家使用;他们将 MySQL 服务器与网络服务器等分开。这使得他们在部署服务器时可以轻松快速地调整少量可调参数。
与此同时,不那么重度的用户通过离开该设置可以获得开箱即用的体面调整。
简短回答:不,它不会比自己设置那些调整选项更能提高性能。
变量innodb_dedicated_server在功能公布时(2017-08-24)有详细解释:
https://mysqlserverteam.com/plan-to-improve-the-out-of-the-box-experience-in-mysql-8-0/
它只是 shorthand 多个调整选项。新变量不会以任何特殊方式提高性能,它与您自己设置其他调整选项完全相同。
当他们宣布该功能时,我在博客上写了这条评论:
I’m sorry, but I don’t like this feature at all. I understand the goal
of improving the out-of-the-box experience for naive users, but I
don’t think this solution will be successful at this goal.
Trying to pre-tune a MySQL installation with some formula is a
one-size-fits-all solution, and these kinds of solutions are
unreliable. We can recall examples of other products that have tried
to do this, but eventually removed their auto-tuning features.
It’s not a good assumption that the buffer pool needs as much physical
RAM as you can afford. You already know this, because you need the
innodb_dedicated_server option. Rick mentioned the possibility that
the dataset is already smaller than RAM. In this case, adding more RAM
has little or no benefit.
Many naive users mistakenly believe (after reading some blog) that
increasing RAM allocation always increases performance. It’s difficult
to explain to them why this is not true.
Likewise innodb log file. We assume that bigger is better, because of
benchmarks showing that heavy write traffic benefits from bigger log
files, because of delaying checkpoints. But what if you don’t have
heavy write traffic? What if you use MySQL for a blog or a CMS that is
99% reads? The large log file is unnecessary. Sizing it for an assumed
workload or dataset size has a high chance of being the wrong choice
for tuning.
I understand the difficulty of asking users questions during
installation. I recently did a project automating MySQL provisioning
with apt. It was annoying having to figure out debconf to work around
the installation prompts that do exist (btw, please document MySQL’s
debconf variables!).
There’s also the problem that even if you do prompt the user for
information, they don’t know the answers to the questions. This is
especially true of the naive users that you’re targeting with this
feature.
If the installer asks “Do you use MySQL on a dedicated server?” do
they even know what this means? They might think “dedicated” is simply
the opposite of shared hosting.
If the installer asks “Do you want to use all available memory on this
system?” you will be surprised at how many users think “memory” refers
to disk space, not RAM.
In short: (1) Using formulas to tune MySQL is error-prone. (2) Asking
users to make choices without information is error-prone.
I have an alternative suggestion: Make it easier for users to become
less naive about their choices.
I think users need a kind of friendly cheat-sheet or infographic of
how to make tuning decisions. This could include a list of questions
about their data size and workload, and then a list of performance
indicators to monitor and measure, like buffer pool page create rate,
and log file write rate. Give tips on how to measure these things,
what config options to change, and then how to measure again to verify
that the change had the desired effect.
A simple monitoring tool would also be useful. Nothing so
sophisticated as PMM or VividCortex for long-term trending, but
something more like pt-mext for quick, ephemeral measurements.
The only thing the installation process needs to do is tell the user
that tuning is a thing they need to do (many users don’t realize
this), and refer them to the cheat-sheet documentation.
来自 MySQL8 文档:
When innodb_dedicated_server is enabled, InnoDB automatically configures the following variables:
innodb_buffer_pool_size
innodb_log_file_size
innodb_log_files_in_group (as of MySQL 8.0.14)
innodb_flush_method
Only consider enabling innodb_dedicated_server if the MySQL instance resides on a dedicated server
where it can use all available system resources. Enabling innodb_dedicated_server is not recommended
if the MySQL instance shares system resources with other applications.
假设服务器专用于 MySQL,启用 innodb_dedicated_server 是否真的比我自己调整这些参数提供更好的性能?
刚刚调整。
为所有内容提供“良好”的默认值是一项具有挑战性的任务。最大的障碍是不知道同一台服务器上的其他产品(Java、WordPress 等)运行 会消耗多少机器内存和 CPU。
大量MySQL服务器被大玩家使用;他们将 MySQL 服务器与网络服务器等分开。这使得他们在部署服务器时可以轻松快速地调整少量可调参数。
与此同时,不那么重度的用户通过离开该设置可以获得开箱即用的体面调整。
简短回答:不,它不会比自己设置那些调整选项更能提高性能。
变量innodb_dedicated_server在功能公布时(2017-08-24)有详细解释:
https://mysqlserverteam.com/plan-to-improve-the-out-of-the-box-experience-in-mysql-8-0/
它只是 shorthand 多个调整选项。新变量不会以任何特殊方式提高性能,它与您自己设置其他调整选项完全相同。
当他们宣布该功能时,我在博客上写了这条评论:
I’m sorry, but I don’t like this feature at all. I understand the goal of improving the out-of-the-box experience for naive users, but I don’t think this solution will be successful at this goal.
Trying to pre-tune a MySQL installation with some formula is a one-size-fits-all solution, and these kinds of solutions are unreliable. We can recall examples of other products that have tried to do this, but eventually removed their auto-tuning features.
It’s not a good assumption that the buffer pool needs as much physical RAM as you can afford. You already know this, because you need the innodb_dedicated_server option. Rick mentioned the possibility that the dataset is already smaller than RAM. In this case, adding more RAM has little or no benefit.
Many naive users mistakenly believe (after reading some blog) that increasing RAM allocation always increases performance. It’s difficult to explain to them why this is not true.
Likewise innodb log file. We assume that bigger is better, because of benchmarks showing that heavy write traffic benefits from bigger log files, because of delaying checkpoints. But what if you don’t have heavy write traffic? What if you use MySQL for a blog or a CMS that is 99% reads? The large log file is unnecessary. Sizing it for an assumed workload or dataset size has a high chance of being the wrong choice for tuning.
I understand the difficulty of asking users questions during installation. I recently did a project automating MySQL provisioning with apt. It was annoying having to figure out debconf to work around the installation prompts that do exist (btw, please document MySQL’s debconf variables!).
There’s also the problem that even if you do prompt the user for information, they don’t know the answers to the questions. This is especially true of the naive users that you’re targeting with this feature.
If the installer asks “Do you use MySQL on a dedicated server?” do they even know what this means? They might think “dedicated” is simply the opposite of shared hosting.
If the installer asks “Do you want to use all available memory on this system?” you will be surprised at how many users think “memory” refers to disk space, not RAM.
In short: (1) Using formulas to tune MySQL is error-prone. (2) Asking users to make choices without information is error-prone.
I have an alternative suggestion: Make it easier for users to become less naive about their choices.
I think users need a kind of friendly cheat-sheet or infographic of how to make tuning decisions. This could include a list of questions about their data size and workload, and then a list of performance indicators to monitor and measure, like buffer pool page create rate, and log file write rate. Give tips on how to measure these things, what config options to change, and then how to measure again to verify that the change had the desired effect.
A simple monitoring tool would also be useful. Nothing so sophisticated as PMM or VividCortex for long-term trending, but something more like pt-mext for quick, ephemeral measurements.
The only thing the installation process needs to do is tell the user that tuning is a thing they need to do (many users don’t realize this), and refer them to the cheat-sheet documentation.