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提供的开 ...
随机推荐
- set循环遍历删除特定元素
使用Iterator迭代器 public class Demo { public static void main(String[] args) { Set<Object> obj = n ...
- 关于Xcode9 无法读取文件的问题
以前我们加载本地文件的时候也许没有注意,可是在Xcode9中会出现许多问题,经常会出现图片无法显示,本地html无法加载等问题: 当然不是Xcode的问题,只是以前我们并没有注意,其实Xcode对这些 ...
- table添加行
需求是要实现表格的动态增加与删除,并且保留标题行和首行,找了半天jq插件,没找到合适的,所以自己写了个demo <!DOCTYPE html> <html> <head& ...
- Java作业四
1.先在一个包中编写第一个类ClassA,要求该类中具有四种不同访问权限的成员,再在另一个包中编写第二个类ClassB,并在该类中编写一个方法以访问第一个类中的成员.总结类成员访问控制的基本规则. p ...
- shell怎么判断两个文件内容是否相同
#cat diff_two_file#/bin/sbinfile1=/mnt/mmc/test/aafile2=/mnt/mmc/test/bbdiff $file1 $file2 > /dev ...
- unity3d 九宫密码锁
using UnityEngine;using System.Collections.Generic;using System;using UnityEngine.EventSystems;using ...
- Python实现登陆的功能
import datetimetoday=datetime.datetime.today()# 获取当前时间for i in range(3): username=input("请输入用户名 ...
- [深入理解Java虚拟机]<垃圾收集器与内存分配策略>
Overview 垃圾收集考虑三件事: 哪些内存需要回收? 什么时候回收? 如何回收? 重点考虑Java堆中动态分配和回收的内存. Is Object alive? 引用计数法 给对象添加一个引用计数 ...
- chromium ②
这篇研究两个问题:chromium对线程的封装和进程通信.主要参考chromium的官方技术文档:Treading和Inter-process Communication (IPC). chrome速 ...
- Python 数据共享
import time from multiprocessing import Process,Manager,Lock # a = 10 # # tmp = a # # tmp -= 1 # # a ...