Apply mitigations for piling up open connections

- Because we're using a FastAPI api framework with a Django ORM, we're running into some interesting conditions around connection pooling and clean-up. We're ending up with a large pile-up of open, stale connections to the DB recurringly when the server has been running for a while. To mitigate this problem, given starlette and django run in different python threads, add a middleware that will go and call the connection clean up method in each of the threads.
This commit is contained in:
sabaimran
2024-07-09 12:22:58 +05:30
parent 0b1b262512
commit 4471c1e37f
3 changed files with 40 additions and 12 deletions

View File

@@ -65,7 +65,7 @@ dependencies = [
"tenacity == 8.3.0",
"anyio == 3.7.1",
"pymupdf >= 1.23.5",
"django == 4.2.11",
"django == 5.0.6",
"authlib == 1.2.1",
"llama-cpp-python == 0.2.76",
"itsdangerous == 2.1.2",