我有很多点对点HTTP 代理,我需要均匀地分配我的请求,所以我添加了多个缓存对等体指令和设置循环赛作为对等选择算法。这是我的配置:
# Basic configuration
visible_hostname squid_proxy_1
unique_hostname squid_proxy_1
http_port 3130
pid_filename /vagrant/squid_proxy_1.pid
cache deny all
http_access allow all
# Proxies
cache_peer MY_PROXY_HOST parent PROXY_PORT 0 round-robin no-query name=FIRST login=MY_PROXY_LOGIN-1:PASSWORD1
cache_peer MY_PROXY_HOST parent PROXY_PORT 0 round-robin no-query name=SECOND login=MY_PROXY_LOGIN-2:PASSWORD2
cache_peer MY_PROXY_HOST parent PROXY_PORT 0 round-robin no-query name=THIRD login=MY_PROXY_LOGIN-3:PASSWORD3
never_direct allow all
但我遇到了以下问题:缓存对等体切换并非在每次请求后进行。以下是我的访问日志好像:
sudo tail -f /var/log/squid3/access.log
1460977613.775 23783 127.0.0.1 TCP_MISS/200 11371 GET http://www.google.com/ - ROUNDROBIN_PARENT/104.131.79.140 text/html
1460977621.171 4843 127.0.0.1 TCP_MISS/200 11413 GET http://www.google.com/ - ROUNDROBIN_PARENT/104.131.79.140 text/html
1460977628.367 5583 127.0.0.1 TCP_MISS/200 11412 GET http://www.google.com/ - ROUNDROBIN_PARENT/104.131.79.140 text/html
1460977634.270 4726 127.0.0.1 TCP_MISS/200 11354 GET http://www.google.com/ - ROUNDROBIN_PARENT/104.131.79.140 text/html
1460977642.429 6531 127.0.0.1 TCP_MISS/200 12841 GET http://www.google.com/ - ROUNDROBIN_PARENT/104.131.79.140 text/html
1460977645.563 1747 127.0.0.1 TCP_MISS/200 11360 GET http://www.google.com/ - ROUNDROBIN_PARENT/104.131.79.140 text/html
1460977653.731 7242 127.0.0.1 TCP_MISS/200 11408 GET http://www.google.com/ - ROUNDROBIN_PARENT/107.170.96.123 text/html
1460977658.559 3763 127.0.0.1 TCP_MISS/200 11374 GET http://www.google.com/ - ROUNDROBIN_PARENT/45.55.163.40 text/html
1460977660.516 1387 127.0.0.1 TCP_MISS/200 11398 GET http://www.google.com/ - ROUNDROBIN_PARENT/45.55.163.40 text/html
1460977662.863 1758 127.0.0.1 TCP_MISS/200 11414 GET http://www.google.com/ - ROUNDROBIN_PARENT/45.55.163.40 text/html
1460977664.667 1305 127.0.0.1 TCP_MISS/200 11419 GET http://www.google.com/ - ROUNDROBIN_PARENT/45.55.163.40 text/html
1460977676.157 10901 127.0.0.1 TCP_MISS/200 11384 GET http://www.google.com/ - ROUNDROBIN_PARENT/45.55.163.40 text/html
1460977678.565 1348 127.0.0.1 TCP_MISS/200 11321 GET http://www.google.com/ - ROUNDROBIN_PARENT/45.55.163.40 text/html
1460977681.742 2516 127.0.0.1 TCP_MISS/200 11383 GET http://www.google.com/ - ROUNDROBIN_PARENT/45.55.163.40 text/html
确实发生仅当我使用这些特定的 P2P 代理时。我尝试使用我在互联网上找到的免费代理进行相同的配置,并且一切正常。
我猜问题在于我的代理可能被 Squid 视为死机(因为它们有时确实非常慢)并且因此我们不会将流量路由给它们,但我不确定。
有没有办法获取有关对等选择算法的更多信息?我可以调整缓存对等体有没有什么办法可以解决这个问题?
答案1
通过禁止持久连接可以解决此问题。就我而言,我在配置中添加了以下行,现在一切正常。
server_persistent_connections off
非常感谢@BillThor,他在评论部分帮助了我。