2023-03-29

Unexpected Latency in Tinyproxy

I love tinyproxy, it is simple to setup and more than enough for my needs. Recently however I noticed that some clients were experiencing unexpected long delays when doing something as simple as curl google.com. After some sleuthing, I tracked it down to the fact I had

LogLevel Info

in my config. When this is set tinyproxy produces log entries such as

CONNECT   Mar 28 08:46:41 [7023]: Connect (file descriptor 7): [unknown] [123.123.123.123]

the [unknown] is due to tinyproxy attempting and failing to resolve the connecting IP into a hostname. It is this attempt to map IP to hostname that is causing the latencies observed. To resolve this I added offending IP to /etc/hosts

123.123.123.123 some-host-name

with the above entry the latency went away and the log entries now look like

CONNECT   Mar 28 20:39:49 [6879]: Connect (file descriptor 7): some-host-name [123.123.123.123]