Skip to content

Support Min connection pool parameter #3009#3438

Merged
brianc merged 3 commits intobrianc:masterfrom
htrajan:support_min_pool_size
Apr 25, 2025
Merged

Support Min connection pool parameter #3009#3438
brianc merged 3 commits intobrianc:masterfrom
htrajan:support_min_pool_size

Conversation

@htrajan
Copy link
Contributor

@htrajan htrajan commented Apr 23, 2025

My attempt to address #3009

Hopefully this is sensible with the tests I've included

I suspect that lack of this functionality is causing my company's app to frequently hit bottlenecks with allocating new db pool connections

Copy link

@chasdevs chasdevs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; I'm not a maintainer of this library, though 😅

@brianc
Copy link
Owner

brianc commented Apr 24, 2025

nice tests. this looks good to me, tbh! I prefer my pools to drain when my app is idle...feels better to me than leaving a bunch of sockets open doing nothing for > 5 minutes, but I can definitely see in some "needs to be fast, but gets spikey traffic" this could come in handy. That initial connection to the backend is no joke. I've seen it take upwards of a second on GCS in the past.

@htrajan
Copy link
Contributor Author

htrajan commented Apr 24, 2025

nice tests. this looks good to me, tbh! I prefer my pools to drain when my app is idle...feels better to me than leaving a bunch of sockets open doing nothing for > 5 minutes, but I can definitely see in some "needs to be fast, but gets spikey traffic" this could come in handy. That initial connection to the backend is no joke. I've seen it take upwards of a second on GCS in the past.

Great! What would be the next steps to get this into the next release?

@charmander
Copy link
Collaborator

Thoughts on implementing or documenting:

  • prefilling the pool to the minimum
  • maintaining the minimum on connection errors

?

Keepalives are also sort of related to this, but I think any documentation and work needed there stands on its own.

@brianc
Copy link
Owner

brianc commented Apr 25, 2025

Thoughts on implementing or documenting:

  • prefilling the pool to the minimum
  • maintaining the minimum on connection errors

?

I can document that this is not implemented at the moment, and merge this as a first step. Those other things yeah could come in the future.

@brianc brianc merged commit ff40638 into brianc:master Apr 25, 2025
6 checks passed
@brianc brianc mentioned this pull request Apr 25, 2025
@brianc
Copy link
Owner

brianc commented Apr 25, 2025

I will release a new minor version of pg-pool on Monday morning. i don't like doing afternoon/evening releases because I always like to be around and online throughout the day to respond to any unintentional breaking changes or bugs

@htrajan
Copy link
Contributor Author

htrajan commented May 5, 2025

Hi @brianc, I'm not seeing the update in the latest 8.15.6 release. Do you have an ETA on this?

@zyf0330
Copy link

zyf0330 commented Jun 4, 2025

When create connections with number more than min simultaneously, they all will be removed after idleTimeoutMillis.

@brianc
Copy link
Owner

brianc commented Jun 12, 2025

@htrajan @zyf0330 I'm seeing it right here am I missing something?

@htrajan
Copy link
Contributor Author

htrajan commented Jun 12, 2025

@brianc nope, it's all good now. @zyf0330 might have spotted an edge case where my implementation doesn't work. Unfortunately, I'm pretty tied up now and won't have time to look into it in the near future. I was able to deploy the change to my company's application and get the desired outcome of no more pg-pool.connect spikes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants