2

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

user987263
  • 21
  • 2

1 Answers1

1

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.

ukessi
  • 1,381
  • 1
  • 10
  • 15