DanielW

DanielW

Hi all, I’m using a managed DB service where I can optionally set up a connection pool using PgBouncer and set max connections.

Is there any benefit in doing this? Does Ecto’s connection pooling fulfill the same job?

P.S. been reading this forum for a while but finally signed up and first post. Thanks for the help so far!

Showing Posts 1 to 8

keathley

keathley

In my experience you’ll still need PgBouncer along with ecto’s connection pool, especially for high scale deployments.

bazenha

bazenha

Hi! Welcome to the forum! :smiley:

My understanding is that using something like PgBouncer can help you in situations in which for some reason you have to create/remove database connections in a fast way or you want to have more database connections than your database instance actually is supposed to support.

One example that I came personally across was when I was using elixir together with kubernetes. During some of our operations, we would spawn many kubernetes pods at the same time, and all of them would try to get Database connections together. In those times, it would be easy to go over the number database connections that our Postgres instance actually supported.

Another detail that I also came across is that Postgres is apparently not very good at creating and removing database connections (It’s not very fast at that) and what PgBouncer does is to reuse the same Postgres connections and do a sort of connection multiplexing.

I was never in a high scale deployment, so in might case we ended up not needing it at all. And we also didn’t have someone that really understood the tradeoffs of all those DB connection shenanigans. We were happier when we realised that we didn’t need PgBouncer.

DanielW

DanielW OP

I think I may have to use PgBouncer then, I’m deploying to a single node using docker swarm and during upgrades there’s a short period where DB connections are doubled.

I’ll play around with the settings and see which combination works best.

Thanks for the info!

axelson

axelson

Scenic Core Team

I’m not sure if it’s still true but in the past in order to use PGBouncer it was necessary to disable prepared statements in Ecto. Just something to keep in mind.

hauleth

hauleth

Disable named prepared statements. Ecto will use unnamed prepared statements then.

DanielW

DanielW OP

Still required, I’ve added prepare: :unnamed to my Repo config.

axelson

axelson

Scenic Core Team

Ah, thanks for the clarification :+1:

jschaeff

jschaeff

And maybe only if pgpool is set in “transaction pooling” mode (vs “session pooling” mode), see PgBouncer features

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
widianto
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews