a year ago
Our app logs show quick server responses, but the clients are taking 10x as long to get the information. This is intermittent, but consistent and spans across our end points.
The attached images show the log entries from the same request from the point of view of the server and the client. Something strange is going on.
20 Replies
a year ago
this is for the threaded service in the prod env?
Here's some HTTP logs from today. I couldn't find them in the regular log search (is there a way to see them there?).
The response times are showing up as really slow.

a year ago
first thing im noticing is that you are running gunicorn with its default sync workers, the sync workers really arent suitable for production use, can you try switching over to gunicorn with uvicorn event workers, and start with 4 workers
I released an update to use the uvicorn workers. They seem to be working fine, but we're getting an intermittent error. I'm wondering if it could be proxy related?
OperationalError
connection failed: c120:567d::4d:c3b5:bacd", port 5432 failed: FATAL: sorry, too many clients already
connection to server at "fd12:c120:567d::4d:c3b5:bacd", port 5432 failed: FATAL: sorry, too many clients alreadya year ago
how many workers are you running now
a year ago
looks like you are connecting to the database for every thread that is spawned then, you would have to rethink your database client a bit then
I'm using the default django one. It sounds like connection pooling is a natural next step.
a year ago
yeah i think some re-architecturing is going to be required so that you can move away from the slow sync workers
a year ago
Find a way to open a single pool of databases for the global process, right now you are opening a pool for every thread.
I found a pool option for postgres in Django that seems worth a try.
"OPTIONS": {
"pool": True,
},a year ago
Can't hurt to try


