mukul
mukul

Reputation: 111

every request from a django app increasing mysql number of connections

I have a project built using django 1.11 and i am sending a request from my admin view and it is creating a new DB connection on every request(using django development server, runserver).

But the same thing using gunicorn as server does not increase the number of connections in DB it uses same connection that was created in first request.

In my database settings CONN_MAX_AGE is set to 300 which is 5mins. I am sending second request within 5 mins, so it is supposed to use same connection that was created in first request.

Any idea why, with runserver, django is creating new DB connection on every request and not following persistent connections behavior of django ?

Upvotes: 1

Views: 1390

Answers (1)

Sander van Leeuwen
Sander van Leeuwen

Reputation: 3033

From the docs:

The development server creates a new thread for each request it handles, negating the effect of persistent connections. Don’t enable them during development.

Upvotes: 1

Related Questions