MySQL--线程池(Thread Pool)
=================================================================
线程池技术
在MySQL社区版中,MySQL使用one-thread-per-connection的方式来处理数据库连接,即当MySQL客户端与服务器端建立连接时会创建一个线程来专门处理该连接的所有SQL请求。
one-thread-per-connection优缺点:
优点:
one-thread-per-connection方式实现简单,在连接数较少或使用长连接的场景中有保证较小的响应时间。 缺点:
在大量短连接或高并发场景下,one-thread-per-connection方式需要频繁地创建/销毁线程,并在大量线程间进行切换调度,产生较多的上线文切换(context-switch), 导致系统出现性能问题。
在MySQL企业版中,MySQL提供线程池特性,通过创建多个工作线程来共同处理所有连接的SQL请求,控制MYSQL内部线程数量,避免当连接过多时存储引擎创建大量线程,保证数据库在大并发的情况下保持稳定性和持续的吞吐能力。
MySQL线程池解决如下问题:
1、提升CPU Cache的有效率。
2、减少CPU 上线文切换(context-switch)。
3、减少InnoDB内部mutexes资源争抢。 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. With too many threads executing in parallel, context switching overhead is high. This also presents a challenging task 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. 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. https://dev.mysql.com/doc/refman/5.6/en/thread-pool.html
=================================================================
线程池对性能影响


参考链接:
http://www.gpfeng.com/?p=540&utm_source=tuicool&utm_medium=referral
https://blog.csdn.net/z69183787/article/details/52910079
https://blog.csdn.net/a19860903/article/details/52329636
MySQL--线程池(Thread Pool)的更多相关文章
- MySQL线程池(THREAD POOL)的原理
MySQL常用(目前线上使用)的线程调度方式是one-thread-per-connection(每连接一个线程),server为每一个连接创建一个线程来服务,连接断开后,这个线程进入thread_c ...
- C#多线程实现方法——线程池(Thread Pool)
ThreadPool使用 同步机制 ThreadPool使用 需要定义waitcallback委托形式如 public delegate void WaitCallback(object stat ...
- 简易线程池Thread Pool
1. 基本思路 写了个简易的线程池,基本的思路是: 有1个调度线程,负责维护WorkItem队列.管理线程(是否要增加工作线程).调度(把工作项赋给工作线程)等 线程数量随WorkItem的量动态调整 ...
- 线程池 (thread pool) 的类型与实现方式
在许多应用中需要频繁的创建许多生命周期很短的线程,如果用传统方法的话就会造成大量的资源了浪费,java的设计者们考虑到了这点在java中加入了线程池这个特性,它负责管理大量的线程的创建销毁等操作. 首 ...
- 使用boost实现线程池thread pool | boost thread pool example
本文首发于个人博客https://kezunlin.me/post/f241bd30/,欢迎阅读! boost thread pool example Guide boost thread pool ...
- MySQL线程池
MySQL线程池只在Percona,MariaDB,Oracle MySQL企业版中提供.Oracle MySQL社区版并不提供. 在传统方式下,MySQL线程调度方式有两种:每个连接一个线程(one ...
- Mysql线程池优化笔记
Mysql线程池优化我是总结了一个站长的3篇文章了,这里我整理到一起来本文章就分为三个优化段了,下面一起来看看. Mysql线程池系列一(Thread pool FAQ) 首先介绍什么是mys ...
- Mysql线程池系列一:什么是线程池和连接池( thread_pool 和 connection_pool)
thread_pool 和 connection_pool 当客户端请求的数据量比较大的时候,使用线程池可以节约大量的系统资源,使得更多的CPU时间和内存可以高效地利用起来.而数据库连接池的使用 ...
- MySQL学习分享--Thread pool实现
基于<MySQL学习分享--Thread pool>对Thread pool架构设计的详细了解,本文主要对Thread pool的实现进行分析,并根据Mariadb和Percona提供的开 ...
随机推荐
- IO多路复用,select、poll、epoll 编程主要步骤
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- 生成器 Generators
function* quips(name) { yield "你好 " + name + "!"; yield "希望你能喜欢这篇介绍ES6的译文&q ...
- 使用MYSQL数据库实现编程----第二章第三章课堂知识小总结
第二章1:创建数据库create database myschool 2.数据类型 1.整型 int 2.小数 double 精确度要求高的 ----Decimal(18,4) 2222222 ...
- 字符与字符串3——char 的大小
字符变量占用内存的大小,也就是char类型声明的变量,这个变量占多少字节. 一字节 char c = 'A'; printf("%d,%d\n", sizeof(c),sizeof ...
- [Leetcode 739]*还有几天会升温 Daily Temperatures
[题目] Given a list of daily temperatures T, return a list such that, for each day in the input, tells ...
- Unicode与中文转换工具类方法(转)
/* * 中文转unicode编码 */ public static String gbEncoding(final String gbString) { char[] utfBytes = gbSt ...
- 在 Andriod/IOS 程序中使用自定义字体
很早就遇到这个问题,QDAC作者也在这里给出了方案.
- 由于php环境时间与北京时间相差7个小时
故在设置当前时间时候需要加上 date_default_timezone_set('prc'); 或者 在php.ini里面设置date.timezone=prc
- SpringBoot2静态资料访问
在SpringBoot2内要继承WebMvcConfigurationSupport并重写addResourceHandlers方法才能访问到静态资料. @Configuration public c ...
- python的ConfigParser模块
前言 处理配置文件做增.删.改.查 操作. 配置文件的格式如下:“[ ]”包含的为 section,section 下面为类似于 key - value 的配置内容: configparser 默认支 ...