Network latency? Quick responses are loading slowly
rkm3
FREEOP

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

rkm3
FREEOP

a year ago

5d77fb37-1fba-4a55-bbd3-e0fab8243723


rkm3
FREEOP

a year ago

Network latency? Quick responses are loading slowly


a year ago

this is for the threaded service in the prod env?


rkm3
FREEOP

a year ago

Yes


rkm3
FREEOP

a year ago

@Brody sorry for being slow. It's good to see you again.


rkm3
FREEOP

a year ago

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.

1339382768613986300


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


rkm3
FREEOP

a year ago

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 already

rkm3
FREEOP

a year ago

Things are quiet on the database side.

1340022572523454500


a year ago

how many workers are you running now


rkm3
FREEOP

a year ago

4


rkm3
FREEOP

a year ago

The release is clear in the memory chart

1340024380494971000


rkm3
FREEOP

a year ago

Here's a closer view

1340024709340729300


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


rkm3
FREEOP

a year ago

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


rkm3
FREEOP

a year ago

Thanks. I'm new-ish to this type of change. Any pointers are apppreciated.


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.


rkm3
FREEOP

a year ago

I found a pool option for postgres in Django that seems worth a try.

    "OPTIONS": {
            "pool": True,
        },

https://docs.djangoproject.com/en/5.1/ref/databases/


a year ago

Can't hurt to try


Loading...