These sporadic 30–300s response delays typically stem from slow or stalled client reads or rare TCP stalls (packet loss/retransmissions). Your aiohttp app logs “done” after passing data to Gunicorn, while Apache only logs when the client fully receives it. A slow or flaky network/client causes the proxy to hold the socket open, delaying the final Apache log. Checking socket states (ss
, netstat
), Apache’s mod_status
, and TCP retransmissions can confirm this. The rest of the system is likely fine—this is common when dealing with a small fraction of slow or interrupted clients.