Occasional ~4-second wait when using API #14796
-
When calling
Interesting detail:
Example:
--> Something in the NetBox instance made it wait for ~4 seconds and then open a new database connection to get the requested data. When capturing over longer period of time and repeating the API call, it can be seen that a new database TCP connection is quite rare (outside of this wait issue), and that when the wait happens, the previous TCP connections (that were used for the previous API calls) still seem to be there = they were recently used and nobody sent any session-terminating packets on them, but NetBox somehow didn't use the existing database connections but opted to wait and then opened a new database connection to serve the API call. I have to say that this doesn't look load-dependent: any call can be delayed, independent of the time since previous call or other activity on the system.
What do you suggest to improve the situation? The RDS database is Postgres 13.10, the NetBox EC2 instance (Debian 12) has:
Example of a testing script to see the waits happen:
When running I have read https://docs.djangoproject.com/en/4.2/ref/settings/#databases (and about the persistent database connections), didn't see any help there. When running the testing script, within a minute there will be one or more waits. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Observation: If I leave out the token from the testing script, calling
Next, Redis connections, from the capture:
Any ideas from these symptoms? This is running redis-server 7.0.11-1+deb12u1 (but again, this wait problem also occurs on older system that has 6.0.16-1+deb11u2). |
Beta Was this translation helpful? Give feedback.
-
Looks like I managed to explain all this (unless I find something new later...). Two issues:
When using uWSGI, after adding |
Beta Was this translation helpful? Give feedback.
Looks like I managed to explain all this (unless I find something new later...). Two issues: