为什么Squid无法缓存大文件

时间:2019-06-13 16:52:53

标签: caching squid

我对使用Squid并不陌生,并且使用Squid缓存获得了一些意外的结果。我将在下面附加我的squid.conf文件,但基本上我将“ cache_dir”设置为15 GB,将“ cache_mem”设置为7 GB。然后,我尝试下载8GB的文件。

第一次是30MB / s,相对较慢,这是可以预期的,因为尚未使用缓存。我检查了“ sudo du -hs / var / spool / squid”,它应该得到我确定的缓存大小,它说是8 GB,这是预期的。

第二次是300 MB / s,这是快速且预期的。此时,出于某种原因,“ access.log”实际上显示了两个请求的TCP_Miss(我对此进行了多次测试)。然后,第三个请求的速度为30 MB / s,即使对象只是在高速缓存中,这仍然很慢。 “ sudo du -hs / var / spool / squid”表示196K,这意味着该文件不再位于缓存中。第四个请求又快了。

与文件大于cache_mem但小于cache_dir的文件有关吗?在那种情况下,它根本不会被缓存,第二个请求也将非常慢。如果已将其缓存,那么为什么它会在第二个请求之后被踢出,从而使第三个请求变慢。

#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80    # http
acl Safe_ports port 21    # ftp
acl Safe_ports port 443   # https
acl Safe_ports port 70    # gopher
acl Safe_ports port 210   # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280   # http-mgmt
acl Safe_ports port 488   # gss-http
acl Safe_ports port 591   # filemaker
acl Safe_ports port 777   # multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost


#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all


# Squid normally listens to port 3128
http_port 3128

# Uncomment and adjust the following to add a disk cache directory.
maximum_object_size 15 GB
cache_dir ufs /var/spool/squid 15000 16 256
cache_mem 7000 MB
maximum_object_size_in_memory 15 GB
cache_replacement_policy LRU
range_offset_limit -1
quick_abort_min -1 KB

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:   1440  20% 10080
refresh_pattern ^gopher:  1440  0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
refresh_pattern .   0 20% 4320

0 个答案:

没有答案