---
title: "Migrate"
url: "https://docs.yugabyte.com/stable/additional-features/connection-manager-ysql/ycm-migrate/"
---

# Migrate

Migrate to YSQL Connection Manager

How to migrate from your current pooling solution

## PgBouncer

PgBouncer is a generic PostgreSQL connection pooler and Connection Manager is purpose-built for YugabyteDB, optimizing connection management for distributed PostgreSQL (YSQL). Both support transaction pooling, session pooling, or statement pooling.

The following table describes key differences between PgBouncer and YugabyteDB Connection Manager.

Feature PgBouncer YSQL Connection Manager 

Architecture Single node Designed for distributed multi-node connections 

Pooling mode Transaction level (default) Transaction level only 

Pool configuration Creates pool for every combination of users and databases Creates pool for every (user,db) combination 

SQL limitations No support for SQL features such as TEMP TABLE, SET statements, CURSORS, and so on. No equivalent limitations. 

Configuration parameters max\_db\_connections ysql\_max\_connections (core database flag) 

max\_db\_client\_connections ysql\_conn\_mgr\_max\_client\_connections 

min\_pool\_size ysql\_conn\_mgr\_min\_conns\_per\_db 

server\_idle\_timeout ysql\_conn\_mgr\_idle\_time 

server\_lifetime ysql\_conn\_mgr\_server\_lifetime 

tcp\_keepalive ysql\_conn\_mgr\_tcp\_keepalive 

tcp\_keepintvl ysql\_conn\_mgr\_tcp\_keepalive\_keep\_interval 

listen\_port ysql\_conn\_mgr\_port 

Connection string `postgresql://<username>:<password>@<pgbouncer_host>:<pgbouncer_port>/<database_name>?sslmode=require` `postgresql://<username>:<password>@<host>:<port>/<database_name>?sslmode=require`

Connection Manager remains transparent, connection string (by default) is same as without connection manager enabled. 

Scalability Single process/thread. To scale, you need to start multiple instances of PgBouncer. The number of threads for multiplexing is configurable using `ysql_conn_mgr_worker_threads` (default is CPU cores divided by 2).

### Migrate

After reviewing the differences between PgBouncer and Connection Manager, migrate from PgBouncer as follows:

1. Make sure your application works with session-level pooling.
   
   Connection Manager uses session-level pooling. If you are using transaction pooling with PgBouncer, you may need to make changes to your application.
2. Deploy YugabyteDB Connection Manager.
   
   Enable and configure YugabyteDB Connection Manager. Refer to [setup](/stable/additional-features/connection-manager-ysql/ycm-setup/ "setup").
   
   \[How to configure to connect to a local region (without using sticky session).]
3. Update connection strings.
   
   Change your application's database connection URL to point to the YugabyteDB endpoint (default port is 5433).
4. Test in a staging environment.
   
   - Validate connection handling when running your workload.
   - Simulate failover scenarios and node failures.
5. Set up [monitoring](/stable/additional-features/connection-manager-ysql/ycm-monitor/ "monitoring").
   
   - Integrate YugabyteDB metrics into Prometheus, Grafana, Datadog, or your preferred APM.
   - Track active connections, error rates, and latency.
6. Understand how YugabyteDB scales horizontally.
   
   PgBouncer is a single process/thread, and to scale you need to start multiple instances of PgBouncer. Connection manager on the other hand is multi-threaded and creates a number of threads based on the available CPU.
7. Update your failover and high availability strategy.
   
   Make sure your application handles dynamic leader changes. Remove PgBouncer-specific manual failover scripts, if any custom scripts are used to fail over and bring your application online.
