I set DATABASE setting like below and run Django App.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.oracle',
'NAME': 'orcl',
'USER': 'smkim',
'PASSWORD': '1123',
'HOST': '168.192.15.18',
'PORT': '1521',
'CONN_MAX_AGE': 10,
'OPTIONS': {'threaded': True}
}
}
To make sure that if Django open 10 persistent connections, I send a SQL like the below.
SELECT username FROM v$session WHERE username='SMKIM';
However, this command just returns 2 records(This is because I spawn a process, as a result two processes has one connection respectively).
Why does Django only open 2 connections even I set 10 persistent connections?
(ps. the app is using a thread pool(5) )
'CONN_MAX_AGE'
sets the age of one connection before it is closed, and not how many of them there should be, see the docs:
CONN_MAX_AGE
Default: 0
The lifetime of a database connection, in seconds. Use 0 to close database connections at the end of each request — Django’s historical behavior — and None for unlimited persistent connections.
So the connection will be opened when Django needs one and there's no other open connection, though DB can close such 'persistent' connection on it's side. See the docs section for more details.