make connection pool

This commit is contained in:
Mohamed Nouffer
2023-05-03 18:41:58 +05:30
parent 13a5a1969f
commit 0f7cf18ecb
3 changed files with 12 additions and 2 deletions

View File

@ -91,7 +91,7 @@ WSGI_APPLICATION = 'config.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'ENGINE': 'dj_db_conn_pool.backends.postgresql',
'NAME': env("POSTGRES_DBNAME"),
'USER': env("POSTGRES_USER"),
'PASSWORD': env("POSTGRES_PASS"),
@ -100,6 +100,15 @@ DATABASES = {
}
}
DATABASES = {
'default': {
'POOL_OPTIONS' : {
'POOL_SIZE': 200,
'MAX_OVERFLOW': 10,
'RECYCLE': 24 * 60 * 60
}
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

View File

@ -61,7 +61,7 @@ external_pid_file = '/var/run/postgresql/12-main.pid' # write an extra PID fil
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 600 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
# (change requires restart)

View File

@ -64,3 +64,4 @@ urllib3==1.26.7
django-extra-fields==3.0.2
django-phonenumber-field==6.1.0
django-rest-knox==4.2.0
django-db-connection-pool[postgresql]