https://blog.csdn.net/hll814/article/details/50764666
https://www.cnblogs.com/caoshousong/p/10845396.html
常用命令:
show variables like ‘%max_connection%’; 查看最大连接数
set global max_connections=1000; 重新设置最大连接数
show variables like ‘%max_connection%’;
show variables like ‘thread_cache_size’;
set global thread_cache_size=100 短链接设置大一点,长连接小一点
set global thread_cache_size=500;
set global max_connections=1500;
1、django的链接是长链接
2、mysql默认保持连接八小时
3、django的setting文件mysql链接可使用断开链接时间,但是不适用多线程
4、可增加mysql的链接数,改mysql的配置文件my.cnf
5、可在线程调用完毕断开属于此线程的mysql链接
如:
def on_done(future):
# 因为每一个线程都有一个 connections,所以这里可以调用 close_all(),把本线程名下的所有连接关闭。
connections.close_all