Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm currently facing a very strange issue. I did some optimizations in my queries, which improved quite a lot the overall performance for my Django application's GET requests. However, I'm still facing a few very slow ones (1000ms or more). Checking on Elastic APM, I noticed that for all those cases, there was a DB reconnection. While it's obvious those requests would take more time, it's still takes WAY more time than the amount required for the reconnection itself.

I have set the DB_CONN_MAX_AGE to None, therefore the connections themselves shouldn't be closed at all. Which makes me think the reason for the disconnection itself could also indicate the cause for this.

The blue bars represent the amount of time a given transaction took. The total amount of time for this particular request was 1599ms. The DB reconnection took 100ms, the the queries about ~20ms. Adding those up, gives a total time of 120ms.

enter image description here

I'm a bit clueless how to find out where the rest of the 1479ms. I did some load tests locally, but couldn't reproduce this particular issue. Of course is serializations, middlewares, authentication and other things that might add up some time to requests, but not nearly the 1479ms shown here. It certainly related to the DB connection itself, or better yet, something that happens before that. But I'm not sure how to diagnose it. Specially being unable to reproduce this locally.

I'm open to any ideas that could lead to more information on how to solve this problem. Or maybe someone had a similar experience and could share it with me?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
369 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...