8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

7.6.3 MySQL 企业线程池7.6.3 MySQL Enterprise Thread Pool

Note

MySQL 企业线程池是包含在 MySQL 企业版中的一个扩展,这是一个商业产品。要了解更多关于商业产品的信息,请访问 https://www.mysql.com/products/。MySQL Enterprise Thread Pool is an extension included in MySQL Enterprise Edition, a commercial product. To learn more about commercial products, https://www.mysql.com/products/.

MySQL 企业版包括 MySQL Enterprise 线程池,它是通过服务器插件实现的。MySQL 服务器中的默认线程处理模型是为每个客户端连接使用一个线程来执行语句。随着越来越多的客户端连接到服务器并执行语句,整体性能会下降。线程池插件提供了一种替代的线程处理模型,旨在减少开销并提高性能。该插件实现了一个线程池,通过高效管理大量客户端连接的语句执行线程来提升服务器性能。MySQL Enterprise Edition includes MySQL Enterprise Thread Pool, implemented using a server plugin. The default thread-handling model in MySQL Server executes statements using one thread per client connection. As more clients connect to the server and execute statements, overall performance degrades. The thread pool plugin provides an alternative thread-handling model designed to reduce overhead and improve performance. The plugin implements a thread pool that increases server performance by efficiently managing statement execution threads for large numbers of client connections.

线程池解决了使用每个连接一个线程的模型的几个问题:The thread pool addresses several problems of the model that uses one thread per connection:

  • 在高度并行的执行工作负载下,过多的线程栈会使 CPU 缓存几乎无效。线程池促进线程栈的重用,以尽量减少 CPU 缓存占用。Too many thread stacks make CPU caches almost useless in highly parallel execution workloads. The thread pool promotes thread stack reuse to minimize the CPU cache footprint.

  • 当过多的线程并行执行时,上下文切换的开销很高。这也对操作系统的调度程序提出了挑战。线程池控制活动线程的数量,以保持 MySQL 服务器内的并行性在其可以处理的水平,并且适合 MySQL 所运行的服务器主机。With too many threads executing in parallel, context switching overhead is high. This also presents a challenge to the operating system scheduler. The thread pool controls the number of active threads to keep the parallelism within the MySQL server at a level that it can handle and that is appropriate for the server host on which MySQL is executing.

  • 过多的事务并行执行会增加资源争用。在InnoDB中,这会增加持有中央互斥锁的时间。线程池控制事务的启动时机,以确保不会有过多事务并行执行。Too many transactions executing in parallel increases resource contention. In InnoDB, this increases the time spent holding central mutexes. The thread pool controls when transactions start to ensure that not too many execute in parallel.

附加资源Additional Resources

第 A.15 节,“MySQL 8.4 FAQ:MySQL 企业线程池”Section A.15, “MySQL 8.4 FAQ: MySQL Enterprise Thread Pool”