简体   繁体   中英

Python MySQL connection pooling

I've looked through stackoverflow and can see some oldish posts on this and wondered what the current thinking is about pooling connections in Python for MySQL.

We have a set of python processes that are threading with each thread creating a connection to MySQL. This all works fine, but we can have over 150 connections to MySQL.

When I look at the process state in MySQL I can see that most of the connections are asleep most of the time. The application is connecting to a Twitter streaming API so its busy but this only accounts for a few connections.

Is there a good way of adding connection pooling to Python MySQL and can this be done simply without re-writing all of the existing code?

Many thanks.

PT

See DBUtils

Maybe you have an abstract layer for MySQL, you can modify this layer to avoid rewriting all the code.

If not, you have to hack your Python-MySQL driver.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM