Back to Silas S. Brown's home page
Polipo2: a caching Web proxy forked from Polipo
Polipo2 is a small caching web proxy with an easily-readable data format. It runs fast when handling a few connections, but Squid is better for extreme loads (see performance below), andnginx
with ngx_http_proxy_connect_module
is likely better if you don't want to cache (Polipo2's cache is an integral part of its operation and cannot be disabled; you could also set up Tinyproxy as a non-caching proxy but it might be less reliable than nginx).Polipo2 is a 2017 fork of Juliusz Chroboczek's "Polipo" [octopus] after he ceased maintaining the original in 2016.
Polipo2 is not intended for general client-side use---as Juliusz said when he stepped down, caching proxies are becoming obsolete for general use on the client side due to the increasing prevalence of encrypted alternatives to HTTP that reduce caching proxies to simple relays. If all you want is a simple relay (for example so your Web traffic originates from a remote IP address), then you can do better by using a VPN or a SOCKS5 proxy.
Polipo2 is now intended as a drop-in caching layer for
experimental HTTP proxies such as Web Adjuster
(see Adjuster's --upstream-proxy option; I suggest increasing polipo2's serverSlots and serverMaxSlots when used with parentProxy=
Polipo2 is available on GitHub, and on a suitably well-provisioned GNU/Linux system you can do:
git clone https://github.com/ssb22/polipo2.git cd polipo2 make sudo make installthe last step being optional (you can run polipo2 directly from your user account, e.g. ./polipo2 logFile=
Performance
Polipo2 (like the original Polipo) uses the POSIXpoll()
system call (like 4.2BSD's select()
without the 1024-socket limit) to monitor its in-progress connections from a single thread. It does not use the more advanced epoll
/kqueue
mechanism that modern versions of large-scale proxies like Squid can use (and that Tornado and hence Web Adjuster can use) on the GNU/Linux and BSD platforms.
The problem with poll()
is, it can monitor a huge number of connections at once to tell your code when one or more of them needs processing, but it doesn't tell you which ones need this processing. So when poll()
returns, Polipo2 has to spend CPU time looping through all of its open connections to see what needs doing. By contrast, Linux's epoll
and BSD's kqueue
can point your code directly at the connections that need attention, eliminating that loop.
This is not an issue if you have only a few dozen connections going at once, but once you're in the tens of thousands, you will notice a CPU holdup from those tens of thousands of extra checks that have to be done every time anything happens on any connection!
If that's your situation, I'd recommend switching to Squid, which is more scalable. I currently have no plans to upgrade Polipo2's poll()
into an epoll
/kqueue
, as Polipo2 is intended for small-scale experimental use (so if you're getting big, "bite the bullet" and install Squid).
- If using Squid with Web Adjuster's --upstream-proxy=:3128, my suggested starting point is --run="squid -N -f squid.conf -u 0" with a
squid.conf
like:http_port 127.0.0.1:3128
http_access allow localhost
cache_peer 127.0.0.1 parent 3129 0 no-query no-digest
never_direct allow all
dead_peer_timeout 99 seconds
access_log none localhost
cache_mem 256 MB
(see Squid'scache_dir
directive if you also want a disk cache)
Polipo2 RAM and disk usage
As with Polipo, Polipo2 does not have options to limit the maximum size of its disk cache. You could periodically purge from a separate process and then sendSIGUSR2
(discard objects) to the running Polipo2, but if the machine is expected to stay up, it's likely easier to run in RAM+swap (by setting diskCacheRoot=""
) and then the size can be constrained more accurately (defaults to 25% of RAM; see note on differences with Polipo below).On the other hand, a non-expiring disk cache is a useful option if you wish to collect a corpus of material from a site as users browse it (without needing to run a 'crawler' which might annoy the site); Polipo2's file format is quite easy for other programs to read. Obviously you'd have to respect the copyright on the resulting material.
Differences from the original Polipo
So far:- If running in RAM only (
diskCacheRoot=""
), Polipo2'schunkHighMark
now defaults to 25% of the physical RAM even on machines above 96M (its default is not limited to 24M as it is whendiskCacheRoot
is set).objectHighMark
defaults to 2048 objects for every 24M inchunkHighMark
. You can still override these of course (rememberchunkHighMark
is in bytes). - Polipo2 contains a little more "defensive code" to catch segmentation faults before they happen.
- Polipo2 does not upset your system administrator by having a home page that says "no longer maintained" in large letters at the top. If I come across additional problems, I intend to either fix them or (in the case of a security problem I can't easily fix) remove or disable the offending functionality so Polipo2 stays 'sysadmin-friendly'.
All material © Silas S. Brown unless otherwise stated.
GitHub is a trademark of GitHub Inc.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
Any other trademarks I mentioned without realising are trademarks of their respective holders.