Postgres not releasing memory

lakshay-13
PROOP

20 days ago

I have a trouble understanding the ram usage on my postgres database instance.

Technically it should use significantly less than what it is using now. My suspicion is your garbage handler is not working properly and costing users a lot.

If I have a 3 gb database, it shouldn't keep using 3 gb of memory, it is potgres should be at max 100mb.
Can someone please look into that, and if it gets fixed, I would like some re-imbursement for my extra costing, since I tried everything else to fix it.

$10 Bounty

5 Replies

Railway
BOT

20 days ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


20 days ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 20 days ago


20 days ago

Hey there!

My guess would be that you have many open client connections. By default, Postgres allows up to 100 concurrent connections. If all of them are active at once (and you’re not using a connection pooler), Postgres can easily use 1 GB+ of memory, since each connection consumes its own memory for query execution.

I suggest putting a connection pooler in front of Postgres (like PgBouncer) or lowering your client’s pool size.

If you’re using an ORM, most of them document how to configure their connection pools as well.

If you choose the pooler route, I posted a guide in another post:

https://station.railway.com/questions/need-guidance-adding-pg-bouncer-to-exist-4e29f0c1#7t8c


crisog

Hey there!My guess would be that you have many open client connections. By default, Postgres allows up to 100 concurrent connections. If all of them are active at once (and you’re not using a connection pooler), Postgres can easily use 1 GB+ of memory, since each connection consumes its own memory for query execution.I suggest putting a connection pooler in front of Postgres (like PgBouncer) or lowering your client’s pool size.If you’re using an ORM, most of them document how to configure their connection pools as well.If you choose the pooler route, I posted a guide in another post:https://station.railway.com/questions/need-guidance-adding-pg-bouncer-to-exist-4e29f0c1#7t8c

lakshay-13
PROOP

20 days ago

It's neither of those problems

  1. I checked active connections, there are barely any. 1, 2 at most

  2. you don't need a bouncer to limit connection, you can do that from code. and that didn't help either (since the connections are already low)


lakshay-13

It's neither of those problemsI checked active connections, there are barely any. 1, 2 at mostyou don't need a bouncer to limit connection, you can do that from code. and that didn't help either (since the connections are already low)

20 days ago

I know I'm asking a lot, just trying to help

If downtime is acceptable, have you tried restarting Postgres? Does the memory usage drop after a restart, and then grow again later? What does memory usage look like right after startup?

Also, do you have any Postgres extensions installed?


crisog

I know I'm asking a lot, just trying to helpIf downtime is acceptable, have you tried restarting Postgres? Does the memory usage drop after a restart, and then grow again later? What does memory usage look like right after startup?Also, do you have any Postgres extensions installed?

lakshay-13
PROOP

20 days ago

already tried that too, it barely dips on restart. climbs instantly. No extensions


Loading...