title: How could I check the number of active sqlalchemy connections in a pool at any given time?
body: <p>I have a situation where sqlalchemy keeps running out of active connections from time to time due to high traffic loads, and I would like to run some tests to verify and optimize the pooling parameters per our use case. However, I cannot find a straightforward way of polling for the count of active connections.</p>
  
  <p>Current setup is on the lines:</p>
  
  <pre><code>args = ...
  mapping = {
          'pool_size': 10,
          'max_overflow': 10,
          'pool_timeout': 30,
          'pool_recycle': 1800
      }
  engine = sqlalchemy.create_engine(*args, **mapping)
  </code></pre>
  
  <p>The max connections on the MySQL server is set to 200 and there are about 20 web servers and celery boxes total connecting to it.</p>