# Postgres and Connection Pooling

DevFeed: [Postgres and Connection Pooling](<https://devfeed.tech/articles/postgres-and-connection-pooling-41170.md>)

Original publisher: [Read original article](<https://www.craigkerstiens.com/2014/05/22/Postgres-and-Connection-Pooling/>)

Author: Map

Published: 2014-05-22T20:55:56Z

Content type: tutorial

Language: en

Sources: [Craig Kerstiens](<https://devfeed.tech/sources/craig-kerstiens.md>)

Topics: [connection pool](<https://devfeed.tech/topics/connection-pool.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [Object-relational mapping](<https://devfeed.tech/topics/orm.md>), [SQLAlchemy](<https://devfeed.tech/topics/sqlalchemy.md>), [Django](<https://devfeed.tech/topics/django.md>), [Rails](<https://devfeed.tech/topics/rails.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>), [SSL](<https://devfeed.tech/topics/ssl.md>)

Tags: [connection-pool](<https://devfeed.tech/tags/connection-pool.md>), [connection-pooling](<https://devfeed.tech/tags/connection-pooling.md>), [database](<https://devfeed.tech/tags/database.md>), [django](<https://devfeed.tech/tags/django.md>), [orm](<https://devfeed.tech/tags/orm.md>), [postgres](<https://devfeed.tech/tags/postgres.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [python](<https://devfeed.tech/tags/python.md>), [rails](<https://devfeed.tech/tags/rails.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [sqlalchemy](<https://devfeed.tech/tags/sqlalchemy.md>), [ssl](<https://devfeed.tech/tags/ssl.md>)

## AI overview

A primer on database connection pooling explains how pooled, persistent, and standalone connections reduce connection-establishment overhead, including SSL negotiation. It discusses framework support in Ruby, Python, Rails, and Django, and notes Postgres connection and memory considerations.

## Source excerpt

Connection pooling is quickly becoming one of the more frequent questions I hear. So here's a primer on it. If there's enough demand I'll follow up a bit further with some detail on specific Postgres connection poolers and setting them up. The basics For those unfamiliar, a connection pool is a group of database connections sitting around that are waiting to be handed out and used. This means when a request comes in a connection is already there whether in your framework or some other pooling process, and then given to your application for that specific request or transaction. In contrast, without any connection pooling your application will have to reach out to your database to establish a connection. While in the most basic sense you may thinking connecting to a database is quick, often theres some overhead here. An example is SSL negotiation that may have to occur which means you're looking at not 1-2 ms but often closer to 30-50. The options There's really two major options when it comes to connection pooling: Framework pooling Standalone pooler Persistent connections Framework pooling Today many modern application frameworks have at least some basic level of connection pooling. This means as your application server starts up it will create a pool of connections to use. It's worth noting that while most modern frameworks have pooling, not all do, and further it may not be enabled by default. If you're using the Sequel ORM for Ruby or SQLAlchemy for Python you're well covered here. Further Rails is in pretty good shape also, though you may want to configure the pool size. For Django it's a bit of a mixed story. For some time Django did not have pooling at all. As of Django 1.6 you now have persistent connections by default and the ability to enable a pool. Persistent connections Persistent connections don't offer all of the benefits of pooling, but can often work well enough. Persistent connections is the act of maintaining a connection to your database once it's