Connection Pool
MySQL :: MySQL Connector/NET Developer Guide :: 4.3 Managing a Connection Pool in Connector/NET https://dev.mysql.com/doc/connector-net/en/connector-net-connections-pooling.html
Resource Usage
Connector/NET runs a background job every three minutes and removes connections from pool that have been idle (unused) for more than three minutes. The pool cleanup frees resources on both client and server side. This is because on the client side every connection uses a socket, and on the server side every connection uses a socket and a thread.
MySQL :: MySQL Connector/Python Developer Guide :: 4.2 Installing Connector/Python from a Binary Distribution https://dev.mysql.com/doc/connector-python/en/connector-python-installation-binary.html
MySQL :: MySQL Connector/Python Developer Guide :: 9.1 Connector/Python Connection Pooling https://dev.mysql.com/doc/connector-python/en/connector-python-connection-pooling.html
cnxpool = mysql.connector.pooling.MySQLConnectionPool(pool_name = "mypool", pool_size = 3, **dbconfig)
Connection Pooling — SQLAlchemy 1.3 Documentation https://docs.sqlalchemy.org/en/13/core/pooling.html?highlight=max_overflow
creator – a callable function that returns a DB-API connection object, same as that of
Pool.creator.pool_size – The size of the pool to be maintained, defaults to 5. This is the largest number of connections that will be kept persistently in the pool. Note that the pool begins with no connections; once this number of connections is requested, that number of connections will remain.
pool_sizecan be set to 0 to indicate no size limit; to disable pooling, use aNullPoolinstead.max_overflow – The maximum overflow size of the pool. When the number of checked-out connections reaches the size set in pool_size, additional connections will be returned up to this limit. When those additional connections are returned to the pool, they are disconnected and discarded. It follows then that the total number of simultaneous connections the pool will allow is pool_size + max_overflow, and the total number of “sleeping” connections the pool will allow is pool_size. max_overflow can be set to -1 to indicate no overflow limit; no limit will be placed on the total number of concurrent connections. Defaults to 10.
timeout – The number of seconds to wait before giving up on returning a connection. Defaults to 30.
use_lifo –
use LIFO (last-in-first-out) when retrieving connections instead of FIFO (first-in-first-out). Using LIFO, a server-side timeout scheme can reduce the number of connections used during non-peak periods of use. When planning for server-side timeouts, ensure that a recycle or pre-ping strategy is in use to gracefully handle stale connections.
Connection Pooling — SQLAlchemy 1.3 Documentation https://docs.sqlalchemy.org/en/13/core/pooling.html?highlight=max_overflow#pool-use-lifo
Using FIFO vs. LIFO
The QueuePool class features a flag called QueuePool.use_lifo, which can also be accessed from create_engine() via the flag create_engine.pool_use_lifo. Setting this flag to Truecauses the pool’s “queue” behavior to instead be that of a “stack”, e.g. the last connection to be returned to the pool is the first one to be used on the next request. In contrast to the pool’s long- standing behavior of first-in-first-out, which produces a round-robin effect of using each connection in the pool in series, lifo mode allows excess connections to remain idle in the pool, allowing server-side timeout schemes to close these connections out. The difference between FIFO and LIFO is basically whether or not its desirable for the pool to keep a full set of connections ready to go even during idle periods:
engine = create_engine(
"postgreql://", pool_use_lifo=True, pool_pre_ping=True)
Above, we also make use of the create_engine.pool_pre_ping flag so that connections which are closed from the server side are gracefully handled by the connection pool and replaced with a new connection.
Note that the flag only applies to QueuePool use.
Connection Pool的更多相关文章
- Cannot get a connection, pool exhausted解决办法
http://blog.163.com/it_message/blog/static/8892051200908102032653/ 连接池(Tomcat+oracle),运行一段时间后就会出现 Ca ...
- tomcat异常: Cannot get a connection, pool exhausted
1 问题描述Web程序在tomcat刚开始运行时速度很快,但过一段时间后发现速度变得很慢. 检查日志输出,发现异常如下:org.apache.commons.dbcp.SQLNestedExcepti ...
- Database Connection Pool Library | Libzdb
Database Connection Pool Library | Libzdb A small, easy to use Open Source Database Connection Pool ...
- java.lang.IllegalStateException: Connection pool shut down
最近使用HttpClient 4.5 使用 CloseableHttpClient 发起连接后,使用CloseableHttpResponse 接受返回结果,结果就报错了,上网查了下,有位stacko ...
- 连接池(Connection Pool)技术
解释: 连接池(Connection Pool)技术的核心思想是:连接复用,通过建立一个数据库连接池以及一套连接使用.分配.管理策略,使得该连接池中的连接可以得到高效.安全的复用,避免了数据库连接频繁 ...
- Firebird Connection pool is full
今天在做Firebird V3.0.3 x64 版本内存测试,本地PC上,准备开启800个事务(保持不关闭),每个事务做些事,尽量不释放内存. 每次测试当事务数达到时,就提示Connection p ...
- jdbc、Connection pool、jndi的理解和关系
一.概念和理解: ①.jdbc:Java Data Base Connectivity,java数据库连接,最为传统的一种方式,直接连接操作数据库,需要连接时创建连接,使用结束时销毁连接. ②.Con ...
- Android开发中使用数据库时出现java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.
最近在开发一个 App 的时候用到了数据库,可是在使用数据库的时候就出现了一些问题,在我查询表中的一些信息时出现了一下问题: Caused by: java.lang.IllegalStateExce ...
- connection pool exhausted
1.发现问题 生产环境发现有一些redis报错日志 connection pool exhausted.如果redis中没有数据 就直接回源 查DB.暂时不会有什么大问题.中文意思是连接池耗尽. 2. ...
- Can not find connection pool config file
暂时未解决 checkActivation=====================true Can Not Parse ConnectionCfg! 2019/10/12-11:23:38 > ...
随机推荐
- ASP.NET中二进制流下载文件时进度条的使用
说明 在下载大文件时,页面会进入假死状态,于是加上一个进度条以标识后台程序正在运行. 目前,做的进度条并不是实时的,并不会根据程序执行的进度正确显示. 目前是将进度条定时加载到90%,然后停止,等待后 ...
- 磁盘配额,通过ManagementClass("Win32_DiskQuota")
C# using System; using System.Collections.Generic; using System.Management; namespace ConsoleApp2 { ...
- 【命令】gunzip命令
gunzip命令是拿来解以.gz格式的压缩包,其语法和参数选项和gzip一样,我们可以使用gzip来实现,请查看:gzip命令使用方法
- Telegraf+Influxdb+Grafana自动化运维监控
概述:Telegraf收集信息,influxdb时序数据库存储数据,grafana平台展示数据,并进行监控告警,组成一个自动化运维监控平台. 一.influxdb InfluxDB是一个由Infl ...
- arp欺骗(理论)
ARP(地址解析协议)在IPv4和以太网的广泛应用,其主要用作将IP地址翻译为以太网的MAC地址. 一.ARP通讯协议过程 局域网的通信不是根据IP地址进行,计算机是根据mac地址来识别一台机器. 每 ...
- easyui中权限分配和添加 前后端代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- Redis基础篇(五)AOF与RDB比较和选择策略
RDB和AOF对比 关于RDB和AOF的优缺点,官网上面也给了比较详细的说明redis.io/topics/pers- RDB 优点: RDB快照是一个压缩过的非常紧凑的文件,保存着某个时间点的数据集 ...
- 本地缓存高性能之王Caffeine
前言 随着互联网的高速发展,市面上也出现了越来越多的网站和app.我们判断一个软件是否好用,用户体验就是一个重要的衡量标准.比如说我们经常用的微信,打开一个页面要十几秒,发个语音要几分钟对方才能收到. ...
- new 的原理和实现
new 运算符内部做了如下四个操作: 创建一个空的简单 JavaScript 对象(即{}): 链接新对象(即设置该新对象的构造函数)到函数对象: 将新创建的对象作为 this 的上下文: 如果该函数 ...
- 废弃fastjson!大型项目迁移Gson保姆级攻略
前言 大家好,又双叒叕见面了,我是天天放大家鸽子的蛮三刀. 在被大家取关之前,我立下一个"远大的理想",一定要在这周更新文章.现在看来,flag有用了... 本篇文章是我这一个多月 ...