[Django]-Django with mysql what does 'maximum number of connections'?

6👍

According to Django documentation related to the database, Django opens a connection to the database when it first makes a database query. It keeps this connection open and reuses it in subsequent requests. Django closes the connection once it exceeds the maximum age defined by CONN_MAX_AGE or when it isn’t usable any longer.

The default value for CONN_MAX_AGE is 0, preserving the historical behavior of closing the database connection at the end of each request. For persistent connections, you need to set CONN_MAX_AGE to any positive number of seconds. For unlimited persistent connections, set it to None.

So answer to your first question depends on the setting of the CONN_MAX_AGE flag value. If it’s set to 0 then yes for each of 10 users, it will use 10 different connections.

In answer to the second question, I think we don’t need to take care of checking for valid connections because I believe the Django database layer performs everything.

You can look over the following URLs, everything is described over there.

Django Databases

Django Persistent DB connections

Hope this will help you.

Leave a comment