Connection pool with PostgreSQL and AWS

With a microservice architecture, several services talk to my PostgresSQL database. If now I want to deploy parts of my application as AWS Lambda functions, how can I avoid terminating the connections?

Reading several articles [ 1 ], [ 2 ], [ 3 ] I realized that PgBouncer might be well suited for my microservice architecture.

Do I need a microservice in front of my database? How to install this using AWS Lambda?

+6
source share
1 answer

According to this thread on the AWS Developer Forum, AWS Lambda tries to reuse the old process whenever possible, making it possible to use the client pool connection.

In my opinion, using a dedicated connection pool in front of your database is always a good idea. In doing so, you minimize the open connection in your database, which may be a consumer of resources. You can find more information for Postgresql in this post.

To my knowledge, AWS does not offer a dedicated service for the connection pool. You can use a dedicated instance for this. For Postgresql, PgBouncer is a good option. It does not require a large processor or a large amount of memory, but you still prefer a network-optimized instance. And be careful, and only with the PgBouncer example do you represent spof in your architecture.

+3
source

All Articles