fewjio
fewjio

Reputation: 25

Do I need to increase max_connections in Postgresql?

I am using this website analytics tool: Umami

I am currently looking at the postgresql.conf file and I see that max_connections is set to 100.

At peak times, my site may have 1000 concurrent users.

Is Postgresql configured to support that, or does the max_connections means it will only support 100 at a time and disregard the other 900 users.

Should I increase this value? Is there anything else I need to increase?

If it helps, I'm using NGINX+Ubuntu to store the Postgresql Database

Upvotes: 0

Views: 394

Answers (2)

Laurenz Albe
Laurenz Albe

Reputation: 247445

Don't mix up "concurrent application users" and "concurrent database queries". If your queries are short, you may be able to handle thousands of application users with a handful of database connections.

Use a connection pool, that way you will get the best efficiency, and you won't risk overloading the database with too many concurrent queries.

Upvotes: 2

Vy Do
Vy Do

Reputation: 52626

Change in postgresql.conf

Sample: https://github.com/postgres/postgres/blob/master/src/backend/utils/misc/postgresql.conf.sample#L64

Few helpful commands:

SHOW max_connections;

default value is 100.

reset

RESET max_connections;

https://www.postgresql.org/docs/current/runtime-config-connection.html#GUC-MAX-CONNECTIONS

As a comment, you can use connection pool by programming language (for example, Java, JDBC): https://jdbc.postgresql.org/documentation/head/datasource.html

I think it is also a good practice.

Upvotes: 0

Related Questions