理论上来数据库的当前连接数不是应该小等于连接池的最大连接数吗,有什么情况会造成连接池里连接已经关闭丢弃,而数据库端还保留该连接吗
以下是druid 配置文件
datasource1:
name: test
url: jdbc:mysql://x?zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
filters: stat
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 600000
minEvictableIdleTimeMillis: 800000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: true
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
以下是数据库配置
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character_set_server=utf8
collation-server=utf8_general_ci
max_connections=10000
lower_case_table_names=1
transaction_isolation=READ-COMMITTED
interactive_timeout=2592000
wait_timeout=2592000
slow_query_log=ON
slow_query_log_file=/var/log/mysql-sql-slow.log
tmp_table_size=2G
max_heap_table_size=32M
innodb_buffer_pool_size=22G
sort_buffer_size=10M
max_length_for_sort_data=8388608
join_buffer_size=18M
read_rnd_buffer_size=8M
innodb_io_capacity_max=4000
innodb_io_capacity=2000
innodb_rollback_on_timeout=ON
以下是生产环境运行时观察到的数据库线程,由于应用服务器有4个实例,所以我理解数据库当前连接数最多不会超过80才对
理论上来数据库的当前连接数应该小等于连接池的最大连接数,但是现有的连接数没有超过最大连接数,你的数据库配置中最大连接数max_connections=10000,你说的应该是druid中的最大活跃数为20
maxActive: 20
这个最大连接池是程序的,线程数32是数据库的;max_connections=10000这个也是数据库的,所以如果我们在使用的时候例如程序20个,一个navicat客户端也是一个