You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've had some issues the past few days with maxing out my number of Postgres connections on a Heroku app of mine, and I realized that Daphne 2.0 doesn't seem to be reusing idle connections. I upgraded the app to use Channels/Daphne 2.0 a few days ago, and didn't have this issue when I was using Channels/Daphne 1.0.
So, I ran the app locally using Gunicorn as well as Daphne 2.0, with everything else the same, and had the same results.
Here's what I mean.
Running gunicorn myapp.wsgi:application
When I log in to my app, Postgres creates a row for this connection:
Is there something I'm misunderstanding here? Or does this seem to be a bug in Daphne?
Edit: The command I'm running to view the connections in psql is SELECT datid, pid, application_name, backend_start, query_start, state, query FROM pg_stat_activity WHERE datname = 'mydatabase' ORDER BY backend_start;
The text was updated successfully, but these errors were encountered:
As a better comparison, I just ran the tests again using Channels/Daphne 1.0 (daphne myapp.asgi:channel_layer), and that reused the idle connections like Gunicorn does.
I've had some issues the past few days with maxing out my number of Postgres connections on a Heroku app of mine, and I realized that Daphne 2.0 doesn't seem to be reusing idle connections. I upgraded the app to use Channels/Daphne 2.0 a few days ago, and didn't have this issue when I was using Channels/Daphne 1.0.
So, I ran the app locally using Gunicorn as well as Daphne 2.0, with everything else the same, and had the same results.
Here's what I mean.
Running
gunicorn myapp.wsgi:application
When I log in to my app, Postgres creates a row for this connection:
When I log out, Postgres reuses the idle row (notice how
query_start
is updated):Running
daphne myapp.asgi:application
Every time I log in or out, a new connection is created:
Is there something I'm misunderstanding here? Or does this seem to be a bug in Daphne?
Edit: The command I'm running to view the connections in
psql
isSELECT datid, pid, application_name, backend_start, query_start, state, query FROM pg_stat_activity WHERE datname = 'mydatabase' ORDER BY backend_start;
The text was updated successfully, but these errors were encountered: