a year ago
db is locking due to too many connections. do I have options within railway to scale?
0 Replies
a year ago
yes you can increase the connection limit, i think postgres has a default of 100 iirc, but counter question, do you need more conncetions or should you add in a connection pooler like pgbouncer?
a year ago
my pgbouncer template assumes you already have a database service in the project thats named Postgres
and as long as you have that it should not need any initial setup from a perspective of deploying the template
a year ago
well lets slow down a tad here, i had assumed you where connecting to the database from a serverless environment and that was causing you to exhaust the 100 connections, but this is just a django app on railway?
a year ago
do you have an idea of why you are hitting the 100 connection limit? how large are your pools? are you running replicas?
No replicas, not sure how large pools would be (if they exist at all). Default django app with default postgres instance, both on railway. We had sub-100 but close to that concurrent users and starting getting the connections dropped
a year ago
oh then maybe your app is opening a database connection for each request? and you arent using a client pool at all?
I suppose not - I'm just using whatever is batteries included with django. So perhaps we're just opening too many connections
a year ago
okay well then pgbouncer isnt needed in this context.
as a temporary fix you can increase the limit by running ALTER SYSTEM SET max_connections = 200;
then restart the deployment.
run SHOW MAX_CONNECTIONS;
to confirm the new limit after the redeploy.
then i would work on getting an in client database pool going
then i would work on getting an in client database pool going
how would I go about doing this / where can I learn?
a year ago
i cant see there not being django documentation for this, their docs are pretty good imo
a year ago
happy to help!
is there a way to connect to a postgres instance directly through railway or does it need to happen via command line?
a year ago
use the DATABASE_URL
variable's value from the databases service variables