10

Having a microservices architecture, multiple services speak to my PostgresSQL database. If I now want to deploy parts of my application as AWS Lambda functions, how can I avoid running out of connections?

Reading a couple of articles [1], [2], [3] I realized PgBouncer may be a good fit for my microservice architecture.

Do I need a "microservice" in front of my database? How to set this up with AWS Lambda?

Jedi
  • 3,088
  • 2
  • 28
  • 47
lony
  • 6,733
  • 11
  • 60
  • 92

1 Answers1

6

According to this thread on AWS developer forum, AWS Lambda try to reuse old process when it's possible, which offers possiblity to use a client connection pooling.

In my opininon, use a dedicated connection pooler in front of your database is always a good idea. With it, you minimize open connection on your database, which can be an resource consumer. You can find more information, for Postgresql, on this blog post

As far as I am aware, AWS doesn't offer a dedicated service for connection pooling. You can use a dedicated instance for this. For Postgresql, PgBouncer is a good option. It doesn't need a heavly cpu or large amount of memory, but you still prefere a network optimized instance. And be careful, with only on instance of PgBouncer, you introduce a spof in your architecture.

kletord
  • 146
  • 5